home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume9 / acm / part03 < prev    next >
Encoding:
Internet Message Format  |  1990-10-09  |  62.6 KB

  1. Path: uunet!snorkelwacker!apple!netcom!amdcad!sun!mipsdal.mips.com
  2. From: riley@mipsdal.mips.com (Riley Rainey)
  3. Newsgroups: comp.sources.x
  4. Subject: v09i071: acm, X aerial combat simulation, Part03/05
  5. Message-ID: <143450@sun.Eng.Sun.COM>
  6. Date: 7 Oct 90 18:13:05 GMT
  7. References: <csx-09i069:acm@uunet.UU.NET>
  8. Sender: news@sun.Eng.Sun.COM
  9. Lines: 2455
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
  13. Posting-number: Volume 9, Issue 71
  14. Archive-name: acm/part03
  15.  
  16. echo x - ./fsim/init.c
  17. sed 's/^X//' >./fsim/init.c <<'*-*-END-of-./fsim/init.c-*-*'
  18. X/*
  19. X *    xflight : an aerial combat simulator for X
  20. X *
  21. X *    Written by Riley Rainey,  riley@mips.com
  22. X *
  23. X *    Permission to use, copy, modify and distribute (without charge) this
  24. X *    software, documentation, images, etc. is granted, provided that this 
  25. X *    comment and the author's name is retained.
  26. X *
  27. X */
  28. X#include "pm.h"
  29. X
  30. Xextern craftType *newCraft();
  31. X
  32. Xint init () {
  33. X
  34. X    FILE    *f;
  35. X    static    VObject    *o1, *o2;
  36. X    int    i;
  37. X    craft    *p;
  38. X
  39. X        for ((i=0, p=stbl); i<MAXSURFACE; (++i, ++p))
  40. X        p->type = CT_FREE;
  41. X
  42. X        for ((i=0, p=ptbl); i<MAXPLAYERS; (++i, ++p)) {
  43. X        p->index = i;
  44. X        p->type = CT_FREE;
  45. X    }
  46. X
  47. X        for ((i=0, p=mtbl); i<MAXPROJECTILES; (++i, ++p))
  48. X        p->type = CT_FREE;
  49. X
  50. X/*    HUDColor = VAllocColor ("#ffc800"); */
  51. X    HUDColor = VAllocColor ("white");
  52. X/*    groundColor = VAllocColor ("#29350B"); */
  53. X/*    groundColor = VAllocColor ("#717844"); */
  54. X    groundColor = VAllocColor ("#879349");
  55. X    whiteColor = VAllocColor ("white");
  56. X    blackColor = VAllocColor ("black");
  57. X
  58. X/*
  59. X * Read in the runway and place it.
  60. X */
  61. X
  62. X    f = fopen ("rwy", "r");
  63. X    stbl[1].type = CT_SURFACE;
  64. X    stbl[1].cinfo = newCraft();
  65. X    stbl[1].cinfo->object = VReadObject(f);
  66. X    fclose (f);
  67. X    stbl[1].Sg.x = 0.0;
  68. X    stbl[1].Sg.y = 0.0;
  69. X    stbl[1].Sg.z = 0.0;
  70. X    stbl[1].curHeading = stbl[1].curPitch = stbl[1].curRoll = 0.0;
  71. X
  72. X    f = fopen ("rwy2", "r");
  73. X    stbl[0].type = CT_SURFACE;
  74. X    stbl[0].cinfo = newCraft();
  75. X    stbl[0].cinfo->object = VReadObject(f);
  76. X    fclose (f);
  77. X    stbl[0].Sg.x = 4000.0;
  78. X    stbl[0].Sg.y = 3000.0;
  79. X    stbl[0].Sg.z = 0.0;
  80. X    stbl[0].curHeading = 300.0 * 3.14159 / 180.0;
  81. X    stbl[0].curPitch = stbl[0].curRoll = 0.0;
  82. X
  83. X    f = fopen ("tower", "r");
  84. X    stbl[2].type = CT_SURFACE;
  85. X    stbl[2].cinfo = newCraft();
  86. X    stbl[2].cinfo->object = VReadObject(f);
  87. X    fclose (f);
  88. X    stbl[2].Sg.x = 4000.0;
  89. X    stbl[2].Sg.y = -700.0;
  90. X    stbl[2].Sg.z = 0.0;
  91. X    stbl[2].curHeading = stbl[2].curPitch = stbl[2].curRoll = 0.0;
  92. X
  93. X    f = fopen ("mtn", "r");
  94. X    stbl[3].type = CT_SURFACE;
  95. X    stbl[3].cinfo = newCraft();
  96. X    stbl[3].cinfo->object = VReadObject(f);
  97. X    fclose (f);
  98. X    stbl[3].Sg.x = 20.0 * NM;
  99. X    stbl[3].Sg.y = 6.0 * NM;
  100. X    stbl[3].Sg.z = 0.0;
  101. X    stbl[3].curHeading = DEGtoRAD (30.0);
  102. X    stbl[3].curPitch = stbl[3].curRoll = 0.0;
  103. X
  104. X    stbl[4].type = CT_SURFACE;
  105. X    stbl[4].cinfo = stbl[3].cinfo;
  106. X    stbl[4].Sg.x = -2.0 * NM;
  107. X    stbl[4].Sg.y = 40.0 * NM;
  108. X    stbl[4].Sg.z = 0.0;
  109. X    stbl[4].curHeading = DEGtoRAD (160.0);
  110. X    stbl[4].curPitch = stbl[4].curRoll = 0.0;
  111. X
  112. X    stbl[5].type = CT_SURFACE;
  113. X    stbl[5].cinfo = stbl[3].cinfo;
  114. X    stbl[5].Sg.x = -2.6 * NM;
  115. X    stbl[5].Sg.y = 43.0 * NM;
  116. X    stbl[5].Sg.z = 0.0;
  117. X    stbl[5].curHeading = DEGtoRAD (160.0);
  118. X    stbl[5].curPitch = stbl[4].curRoll = 0.0;
  119. X
  120. X    stbl[6].type = CT_SURFACE;
  121. X    stbl[6].cinfo = stbl[1].cinfo;
  122. X    stbl[6].Sg.x = -0.6 * NM;
  123. X    stbl[6].Sg.y = 49.0 * NM;
  124. X    stbl[6].Sg.z = 0.0;
  125. X    stbl[6].curHeading = DEGtoRAD (0.0);
  126. X    stbl[6].curPitch = stbl[6].curRoll = 0.0;
  127. X
  128. X    initf16();
  129. X    initmig23();
  130. X    initf16();
  131. X    initmig23();
  132. X    initaim9();
  133. X    initm61a1();
  134. X
  135. X/*
  136. X *  This next little hack insures that the color tables correctly include
  137. X *  colors associated with the aircraft.
  138. X */
  139. X
  140. X    f = fopen ("mig23", "r");
  141. X    o2 = VReadObject (f);
  142. X    fclose (f);
  143. X
  144. X/*
  145. X *  Set time intervals.
  146. X */
  147. X
  148. X    deltaT = (double) UPDATE_INTERVAL / 1000000.0;
  149. X
  150. X    halfDeltaTSquared = 0.5 * deltaT * deltaT;
  151. X
  152. X    return 0;
  153. X}
  154. *-*-END-of-./fsim/init.c-*-*
  155. echo x - ./fsim/placeCraft.c
  156. sed 's/^X//' >./fsim/placeCraft.c <<'*-*-END-of-./fsim/placeCraft.c-*-*'
  157. X/*
  158. X *    xflight : an aerial combat simulator for X
  159. X *
  160. X *    Written by Riley Rainey,  riley@mips.com
  161. X *
  162. X *    Permission to use, copy, modify and distribute (without charge) this
  163. X *    software, documentation, images, etc. is granted, provided that this 
  164. X *    comment and the author's name is retained.
  165. X *
  166. X */
  167. X#include "pm.h"
  168. X
  169. Xvoid placeCraft (obj, poly, cnt)
  170. Xcraft     *obj;
  171. XVPolygon **poly;
  172. Xint     *cnt; {
  173. X
  174. X    int     i, j, k, n;
  175. X    VPoint     *q, tmp;
  176. X    VMatrix     mtx;
  177. X    VPolygon **p;
  178. X
  179. X    j = *cnt;
  180. X
  181. X    VIdentMatrix (&mtx);
  182. X    if (obj->curRoll != 0.0)
  183. X        VRotate (&mtx, XRotation, obj->curRoll);
  184. X    if (obj->curPitch != 0.0)
  185. X        VRotate (&mtx, YRotation, - obj->curPitch);
  186. X    if (obj->curHeading != 0.0)
  187. X        VRotate (&mtx, ZRotation, obj->curHeading);
  188. X    VTranslatePoint (&mtx, obj->Sg);
  189. X
  190. X    if (obj->cinfo->placeProc != NULL) {
  191. X        (*obj->cinfo->placeProc)(obj, &mtx, poly, cnt);
  192. X        return;
  193. X    }
  194. X
  195. X    n = obj->cinfo->object->numPolys;
  196. X    p = obj->cinfo->object->polygon;
  197. X    for (i=0; i<n; ++i) {
  198. X
  199. X        poly[j] = VCopyPolygon(p[i]);
  200. X        for ((k=0, q=poly[j]->vertex); k<poly[j]->numVtces; (++k, ++q)) {
  201. X            VTransform(q, &mtx, &tmp);
  202. X            *q = tmp;
  203. X        }
  204. X        ++j;
  205. X    }
  206. X
  207. X    *cnt = j;
  208. X}
  209. *-*-END-of-./fsim/placeCraft.c-*-*
  210. echo x - ./fsim/makefile
  211. sed 's/^X//' >./fsim/makefile <<'*-*-END-of-./fsim/makefile-*-*'
  212. X#
  213. X# Makefile for acm;  Riley Rainey, 1990
  214. X#
  215. XLDFLAGS = -L../V/lib
  216. XCFLAGS = -g -I../V/lib -systype bsd43
  217. X
  218. XOBFILES = server.o \
  219. X      pm.o \
  220. X      flaps.o \
  221. X      droneCalculations.o\
  222. X      init.o \
  223. X      aim9m.o \
  224. X      m61a1.o \
  225. X      weapon.o \
  226. X      newPlayer.o \
  227. X      newPlane.o \
  228. X      missile.o \
  229. X      missileCalculations.o \
  230. X      update.o \
  231. X      doEvents.o \
  232. X      getStick.o \
  233. X      doViews.o \
  234. X      doRadar.o \
  235. X      placeCraft.o \
  236. X      transpose.o \
  237. X      doScale.o
  238. X
  239. Xall:    acm acms
  240. X
  241. Xacm:    acm.o
  242. X    cc $(CFLAGS) $(LDFLAGS) -o acm acm.o
  243. X
  244. Xacms:    $(OBFILES)
  245. X    cc $(CFLAGS) $(LDFLAGS) -o acms $(OBFILES) -lV -lX11 -lm
  246. X
  247. Xclean:
  248. X    -rm core *.o
  249. X
  250. Xclobber:
  251. X    -rm acm acms *.o core
  252. X
  253. Xtar:
  254. X    tar cv acm acms f16 mig23 aim-9 rwy rwy2 tower mtn bullet
  255. X
  256. XV2tgif:    V2tgif.c
  257. X    cc -O2 -L../V/lib -I../V/lib -o V2tgif V2tgif.c -lV -lX11 -lbsd -lm
  258. X
  259. Xmkdepend: makefile
  260. X    mkdepend -c "cc $(CFLAGS)" -e "/include/d" makefile *.c
  261. X    touch mkdepend
  262. X
  263. X# DO NOT DELETE THIS LINE -- make depend uses it
  264. XV2tgif.o: V2tgif.c ../V/lib/Vlib.h 
  265. Xacm.o: acm.c manifest.h 
  266. Xaim9m.o: aim9m.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  267. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  268. XdoEvents.o: doEvents.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  269. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  270. XdoRadar.o: doRadar.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  271. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  272. XdoScale.o: doScale.c scale.h 
  273. XdoViews.o: doViews.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  274. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  275. XdroneCalculations.o: droneCalculations.c pm.h manifest.h eng.xbm \
  276. X    flaps0.xbm flaps1.xbm flaps2.xbm flaps3.xbm scale.h \
  277. X    ../V/lib/Vlib.h 
  278. Xflaps.o: flaps.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  279. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  280. XgetStick.o: getStick.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  281. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  282. Xinit.o: init.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm flaps2.xbm \
  283. X    flaps3.xbm scale.h ../V/lib/Vlib.h 
  284. Xm61a1.o: m61a1.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  285. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  286. Xmissile.o: missile.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  287. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  288. XmissileCalculations.o: missileCalculations.c pm.h manifest.h eng.xbm \
  289. X    flaps0.xbm flaps1.xbm flaps2.xbm flaps3.xbm scale.h \
  290. X    ../V/lib/Vlib.h 
  291. XnewPlane.o: newPlane.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  292. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  293. XnewPlayer.o: newPlayer.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  294. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  295. XplaceCraft.o: placeCraft.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  296. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  297. Xpm.o: pm.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm flaps2.xbm \
  298. X    flaps3.xbm scale.h ../V/lib/Vlib.h 
  299. Xserver.o: server.c manifest.h 
  300. Xtranspose.o: transpose.c ../V/lib/Vlib.h 
  301. Xupdate.o: update.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  302. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  303. Xweapon.o: weapon.c pm.h manifest.h eng.xbm flaps0.xbm flaps1.xbm \
  304. X    flaps2.xbm flaps3.xbm scale.h ../V/lib/Vlib.h 
  305. X# DO NOT DELETE THIS 2nd LINE -- make depend uses it
  306. *-*-END-of-./fsim/makefile-*-*
  307. echo x - ./fsim/newPlane.c
  308. sed 's/^X//' >./fsim/newPlane.c <<'*-*-END-of-./fsim/newPlane.c-*-*'
  309. X/*
  310. X *    xflight : an aerial combat simulator for X
  311. X *
  312. X *    Written by Riley Rainey,  riley@mips.com
  313. X *
  314. X *    Permission to use, copy, modify and distribute (without charge) this
  315. X *    software, documentation, images, etc. is granted, provided that this 
  316. X *    comment and the author's name is retained.
  317. X *
  318. X */
  319. X#include "pm.h"
  320. X#include <stdio.h>
  321. X#include <string.h>
  322. X
  323. Xstatic craftType ctype[MAXCRAFTTYPES];
  324. X
  325. X#ifndef SYSV
  326. Xextern char * malloc();
  327. X
  328. Xchar *strdup (s)
  329. Xchar    *s; {
  330. X    char    *p;
  331. X
  332. X    p = malloc (strlen(s)+1);
  333. X    strcpy (p, s);
  334. X    return p;
  335. X}
  336. X#endif
  337. X
  338. XcraftType *lookupCraft (name)
  339. Xchar * name; 
  340. X{
  341. X    int    i;
  342. X
  343. X    for (i=0; i<MAXCRAFTTYPES; ++i)
  344. X        if (ctype[i].name != (char *) NULL)
  345. X        if (strcmp(name, ctype[i].name) == 0)
  346. X            return &ctype[i];
  347. X
  348. X    return (craftType *) NULL;
  349. X}
  350. X
  351. XcraftType *newCraft () {
  352. X
  353. X    int    i;
  354. X    
  355. X    for (i=0; i<MAXCRAFTTYPES; ++i)
  356. X        if (ctype[i].name == (char *) NULL) {
  357. X            ctype[i].name = "*allocated*";
  358. X            return &ctype[i];
  359. X        }
  360. X
  361. X    return (craftType *) NULL;
  362. X}
  363. X
  364. Xvoid initf16 () {
  365. X
  366. X    int      i;
  367. X    FILE        *f;
  368. X    craftType    *c;
  369. X
  370. X    c = newCraft();
  371. X    c->name = strdup("f-16c");
  372. X    c->CLOrigin = 0.129871;
  373. X    c->CLSlope = 3.24778;
  374. X    c->CLNegStall = -17.0 * pi / 180.0;
  375. X    c->CLPosStall =  26.0 * pi / 180.0;
  376. X
  377. X    c->aspectRatio = 3.0;
  378. X
  379. X    c->CDOrigin = 0.03642;
  380. X    c->CDFactor = -2.54200;
  381. X    c->CDPhase = 0.0349066;
  382. X
  383. X    c->CDBOrigin = 1.0;
  384. X    c->CDBFactor = -1.0;
  385. X    c->CDBPhase = 0.0;
  386. X
  387. X    c->CLbeta = -0.8;    /* based on 60 ft^2 tail; CL = 1.0; Ivz = 4.0 ft */
  388. X
  389. X    c->CMOrigin = 0.0;
  390. X    c->CMFactor = -0.95;
  391. X
  392. X    c->CNOrigin = 0.0;
  393. X    c->CNFactor = -7.50;    /* based on 60 ft^2 tail; CL = 1.0; Ivx = 15 ft */
  394. X
  395. X    c->effElevator = 0.50;
  396. X    c->effAileron = 0.70;
  397. X    c->effRudder = 0.30;
  398. X
  399. X    c->maxFlap = 40.0 * pi / 180.0;    /* 40 degree maximum flap setting */
  400. X    c->cFlap = 0.64279;        /* yields Clift of 1.0 at max extension */
  401. X    c->flapRate = 0.1745;        /* about 4 seconds to fully extend flaps */
  402. X
  403. X    c->maxSpeedBrake = DEGtoRAD (80.0);
  404. X    c->cSpeedBrake = 0.02;        /* drag coefficient added by speed brakes */
  405. X    c->speedBrakeRate = DEGtoRAD (40.0); /* about 0.25 seconds to fully extend */
  406. X    c->speedBrakeIncr = DEGtoRAD (80.0); /* one keystoke means full extension */
  407. X
  408. X    VIdentMatrix(&(c->I));
  409. X    c->I.m[0][0] =  50000.0;
  410. X    c->I.m[1][1] = 120000.0;
  411. X    c->I.m[2][2] = 125000.0;
  412. X    c->LDamp = 200000.0;
  413. X    c->MDamp = 1000000.0;
  414. X    c->NDamp = 3600000.0;
  415. X    c->cmSlope = -1.88;
  416. X    c->cmFactor = -1.00;
  417. X    c->cnSlope = 1.00;
  418. X    c->cnFactor = 0.50;
  419. X    c->betaStall = 15.0 * pi / 180.0;
  420. X
  421. X    c->wingS = 300.0;
  422. X    c->emptyWeight = 14576.0;
  423. X    c->maxFuel = 6972.0;
  424. X
  425. X/*
  426. X * Engine data for F100-PW-100
  427. X * source "Modern Combat Aircraft Design", Klaus Huenecke
  428. X */
  429. X
  430. X    c->maxThrust = 14080.0;
  431. X    c->maxABThrust = 23540.0;
  432. X    c->spFuelConsump = 0.68;
  433. X    c->spABFuelConsump = 2.55;
  434. X
  435. X    c->groundingPoint.x = 0.0;
  436. X    c->groundingPoint.y = 0.0;
  437. X    c->groundingPoint.z = 6.0;
  438. X    c->viewPoint.x = 12.5;
  439. X    c->viewPoint.y = 0.0;
  440. X    c->viewPoint.z = -3.0;
  441. X    c->crashC = 90.0;
  442. X
  443. X    c->sCount = 3;
  444. X    c->wStation[0].x = 7.0;
  445. X    c->wStation[0].y = -4.0;
  446. X    c->wStation[0].z = 0.0;
  447. X    c->wStation[1].x = 0.357;
  448. X    c->wStation[1].y = 15.6;
  449. X    c->wStation[1].z = 0.0;
  450. X    c->wStation[2].x = 0.357;
  451. X    c->wStation[2].y = -15.6;
  452. X    c->wStation[2].z = 0.0;
  453. X
  454. X    c->muStatic = 0.08;
  455. X    c->muKinetic = 0.05;
  456. X    c->muBStatic = 0.7;
  457. X    c->muBKinetic = 0.6;
  458. X
  459. X    c->maxNWDef = 1.27; /* 72.7 degrees */
  460. X    c->NWIncr = 1.27 / 32.0;
  461. X    c->maxNWS = 100.0 * 6076.0 / 3600.0;
  462. X    c->gearD1 = 13.5;
  463. X    c->gearD2 = -2.5;
  464. X    f = fopen ("f16", "r");
  465. X    c->object = VReadObject(f);
  466. X    fclose (f);
  467. X
  468. X    c->TEWSThreshold = 0.0;        /* zero, for now */
  469. X    c->radarOutput = 15000.0;    /* estimated */
  470. X    c->radarDRange = 80.0 * NM;
  471. X    c->radarTRange = 60.0 * NM;
  472. X
  473. X    c->placeProc = NULL;
  474. X
  475. X}
  476. X
  477. Xvoid initmig23 () {
  478. X
  479. X    int      i;
  480. X    FILE        *f;
  481. X    craftType    *c;
  482. X
  483. X    c = newCraft();
  484. X    c->name = strdup("mig-23");
  485. X    c->CLOrigin = 0.129871;
  486. X    c->CLSlope = 3.24778;
  487. X    c->CLNegStall = -17.0 * pi / 180.0;
  488. X    c->CLPosStall =  26.0 * pi / 180.0;
  489. X
  490. X    c->aspectRatio = 2.27;
  491. X
  492. X    c->CDOrigin = 0.03642;
  493. X    c->CDFactor = -2.54200;
  494. X    c->CDPhase = 0.0349066;
  495. X
  496. X    c->CDBOrigin = 1.0;
  497. X    c->CDBFactor = -1.0;
  498. X    c->CDBPhase = 0.0;
  499. X
  500. X    c->CMOrigin = 0.0;
  501. X    c->CMFactor = -0.95;
  502. X
  503. X    c->CNOrigin = 0.0;
  504. X    c->CNFactor = -0.90;
  505. X
  506. X    c->effElevator = 0.50;
  507. X    c->effAileron = 0.70;
  508. X    c->effRudder = 0.30;
  509. X
  510. X    c->maxFlap = 40.0 * pi / 180.0;    /* 40 degree maximum flap setting */
  511. X    c->cFlap = 0.64279;        /* yields Clift of 1.0 at max extension */
  512. X    c->flapRate = 0.1745;        /* about 4 seconds to fully extend flaps */
  513. X
  514. X    c->maxSpeedBrake = DEGtoRAD (80.0);
  515. X    c->cSpeedBrake = 0.02;        /* drag coefficient added by speed brakes */
  516. X    c->speedBrakeRate = DEGtoRAD (40.0); /* about 0.25 seconds to fully extend */
  517. X    c->speedBrakeIncr = DEGtoRAD (80.0); /* one keystoke means full extension */
  518. X
  519. X    VIdentMatrix(&(c->I));
  520. X    c->I.m[0][0] =  60000.0;
  521. X    c->I.m[1][1] = 180000.0;
  522. X    c->I.m[2][2] = 195000.0;
  523. X    c->LDamp =  700000.0;
  524. X    c->MDamp = 1000000.0;
  525. X    c->NDamp = 1000000.0;
  526. X    c->cmSlope = -1.88;
  527. X    c->cmFactor = -1.00;
  528. X    c->cnSlope = 1.00;
  529. X    c->cnFactor = 0.50;
  530. X    c->betaStall = 15.0 * pi / 180.0;
  531. X
  532. X    c->wingS = 325.0;
  533. X    c->emptyWeight = 25000.0;
  534. X    c->maxFuel = 9914.0;
  535. X/*
  536. X * Engine data for Tumansky R-29B
  537. X * source "Modern Fighter Combat"
  538. X */
  539. X
  540. X    c->maxThrust = 17635.0;
  541. X    c->maxABThrust = 25350.0;
  542. X    c->spFuelConsump = 0.68;
  543. X    c->spABFuelConsump = 2.55;
  544. X
  545. X    c->groundingPoint.x = 0.0;
  546. X    c->groundingPoint.y = 0.0;
  547. X    c->groundingPoint.z = 6.0;
  548. X    c->viewPoint.x = 12.5;
  549. X    c->viewPoint.y = 0.0;
  550. X    c->viewPoint.z = -3.0;
  551. X    c->crashC = 90.0;
  552. X
  553. X    c->sCount = 3;
  554. X    c->wStation[0].x = 7.0;
  555. X    c->wStation[0].y = -4.0;
  556. X    c->wStation[0].z = 0.0;
  557. X    c->wStation[1].x = 0.357;
  558. X    c->wStation[1].y = 15.6;
  559. X    c->wStation[1].z = 0.0;
  560. X    c->wStation[2].x = 0.357;
  561. X    c->wStation[2].y = -15.6;
  562. X    c->wStation[2].z = 0.0;
  563. X
  564. X    c->muStatic = 0.08;
  565. X    c->muKinetic = 0.05;
  566. X    c->muBStatic = 0.7;
  567. X    c->muBKinetic = 0.6;
  568. X
  569. X    c->maxNWDef = 1.27; /* 72.7 degrees */
  570. X    c->NWIncr = 1.27 / 32.0;
  571. X    c->maxNWS = 100.0 * 6076.0 / 3600.0;
  572. X    c->gearD1 = 13.5;
  573. X    c->gearD2 = -2.5;
  574. X    f = fopen ("mig23", "r");
  575. X    c->object = VReadObject(f);
  576. X    fclose (f);
  577. X    
  578. X    c->TEWSThreshold = 0.0;        /* zero, for now */
  579. X    c->radarOutput = 15000.0;    /* estimated */
  580. X    c->radarDRange = 80.0 * NM;
  581. X    c->radarTRange = 30.0 * NM;
  582. X
  583. X    c->placeProc = NULL;
  584. X
  585. X}
  586. X
  587. Xint newPlane(planeType)
  588. Xchar *planeType; {
  589. X
  590. X    int     i, j;
  591. X    craft    *c;
  592. X
  593. X    for (i=0; i<MAXPLAYERS; ++i) {
  594. X        if (ptbl[i].type == CT_FREE) {
  595. X
  596. X            c = &ptbl[i];
  597. X            c->type = CT_PLANE;
  598. X            c->cinfo = lookupCraft (planeType);
  599. X            c->fuel = c->cinfo->maxFuel;
  600. X
  601. X            c->Cg.x = 0.0;
  602. X            c->Cg.y = 0.0;
  603. X            c->Cg.z = 0.0;
  604. X            c->Sg.x = 40.0;
  605. X            c->Sg.y = 0.0;
  606. X            c->Sg.z = - c->cinfo->groundingPoint.z;
  607. X            c->prevSg = c->Sg;
  608. X
  609. X            c->p = c->q = c->r = 0.0;
  610. X            c->Se = c->Sr = c->Sa = 0.0;
  611. X
  612. X            c->throttle = 1024;
  613. X            c->curThrust = calcThrust (c);
  614. X            c->curFlap = 0.0;
  615. X            c->flapSetting = 0.0;
  616. X            c->curSpeedBrake = 0.0;
  617. X            c->speedBrakeSetting = 0.0;
  618. X            c->curHeading = c->curPitch = c->curRoll = 0.0;
  619. X            VIdentMatrix(&(c->trihedral));
  620. X            c->Itrihedral = c->trihedral;
  621. X            c->groundContact = 1;
  622. X            c->curNWDef = 0.0;
  623. X            c->flags = FL_NWS;
  624. X            c->radarMode = RM_NORMAL;
  625. X            c->curRadarTarget = -1;
  626. X            c->viewDirection.x = 1.0;
  627. X            c->viewDirection.y = 0.0;
  628. X            c->viewDirection.z = 0.0;
  629. X            c->viewUp.x = 0.0;
  630. X            c->viewUp.y = 0.0;
  631. X            c->viewUp.z = -1.0;
  632. X            for (j=0; j<3; ++j) {
  633. X                c->leftHUD[j] = malloc (32);
  634. X                c->rightHUD[j] = malloc (32);
  635. X            }
  636. X
  637. X            c->curWeapon = WEAPONTYPES - 1;
  638. X            selectWeapon (c);
  639. X
  640. X/* a trick to select a valid weapon */
  641. X
  642. X/*
  643. X * give the player 8 Sidewinders and a cannon.
  644. X */
  645. X
  646. X            c->station[0].type = WK_M61A1;
  647. X            c->station[0].info = 500;
  648. X            c->station[0].info2 = 0;
  649. X            c->station[0].info3 = 0;
  650. X            c->station[1].type = WK_AIM9M;
  651. X            c->station[2].type = WK_AIM9M;
  652. X            c->station[3].type = WK_AIM9M;
  653. X            c->station[4].type = WK_AIM9M;
  654. X            c->station[5].type = WK_AIM9M;
  655. X            c->station[6].type = WK_AIM9M;
  656. X            c->station[7].type = WK_AIM9M;
  657. X            c->station[8].type = WK_AIM9M;
  658. X            break;            
  659. X        }
  660. X    }
  661. X
  662. X    if (i == MAXPLAYERS)
  663. X        return -1;
  664. X
  665. X    return i;
  666. X}
  667. X
  668. Xint newDrone(p)
  669. Xcraft *p; {
  670. X
  671. X
  672. X    int     i, j;
  673. X    craft    *c;
  674. X    VPoint    s;
  675. X
  676. X    for (i=0; i<MAXPLAYERS; ++i) {
  677. X        if (ptbl[i].type == CT_FREE) {
  678. X
  679. X            c = &ptbl[i];
  680. X            *c = *p;
  681. X
  682. X            c->index = i;
  683. X            c->team = i;
  684. X
  685. X            c->vl = NULL;
  686. X            c->type = CT_DRONE;
  687. X            c->cinfo = lookupCraft ("f-16c");
  688. X
  689. X/*
  690. X *  Position the drone 200 feet ahead of the player's craft.
  691. X */
  692. X
  693. X            s.x = 400.0;
  694. X            s.y = 30.0;
  695. X            s.z = 0.0;
  696. X            VTransform (&s, &(p->trihedral), &(c->Sg));
  697. X            c->Sg.x += p->Sg.x;
  698. X            c->Sg.y += p->Sg.y;
  699. X            c->Sg.z += p->Sg.z;
  700. X            c->prevSg = c->Sg;
  701. X
  702. X/*            c->p = c->q = c->r = 0.0;
  703. X            c->Se = c->Sr = c->Sa = 0.0;
  704. X
  705. X            c->throttle = 1024;
  706. X            c->curThrust = calcThrust (c);
  707. X            c->curHeading = c->curPitch = c->curRoll = 0.0;
  708. X            VIdentMatrix(&(c->trihedral));
  709. X            c->Itrihedral = c->trihedral;
  710. X*/
  711. X            c->groundContact = 0;
  712. X            c->curNWDef = 0.0;
  713. X            c->flags = 0;
  714. X            c->radarMode = RM_NORMAL;
  715. X
  716. X            for (j=0; j<3; ++j) 
  717. X                c->leftHUD[j] = c->rightHUD[j] = NULL;
  718. X
  719. X            break;            
  720. X        }
  721. X    }
  722. X
  723. X    if (i == MAXPLAYERS)
  724. X        return -1;
  725. X
  726. X    return i;
  727. X}
  728. *-*-END-of-./fsim/newPlane.c-*-*
  729. echo x - ./fsim/doEvents.c
  730. sed 's/^X//' >./fsim/doEvents.c <<'*-*-END-of-./fsim/doEvents.c-*-*'
  731. X/*
  732. X *    xflight : an aerial combat simulator for X
  733. X *
  734. X *    Written by Riley Rainey,  riley@mips.com
  735. X *
  736. X *    Permission to use, copy, modify and distribute (without charge) this
  737. X *    software, documentation, images, etc. is granted, provided that this 
  738. X *    comment and the author's name is retained.
  739. X *
  740. X */
  741. X#include "pm.h"
  742. X#include <X11/Xutil.h>
  743. X#include <X11/keysym.h>
  744. X
  745. X#define MAX_MAPPED_STRING_LEN    10
  746. X#define MAX_POPUP_STRING_LEN    40
  747. X
  748. Xextern int cur;
  749. X
  750. Xvoid doEvents(c)
  751. Xcraft *c; 
  752. X{
  753. X
  754. X    XEvent        ev;
  755. X    viewer        *u;
  756. X    int        player;
  757. X    double        scale;
  758. X
  759. X/*
  760. X *  Process events for each player and any "back seaters"
  761. X */
  762. X
  763. X    player = 1;
  764. X    for (u=c->vl; u != (viewer *) NULL; u=u->next) {
  765. X
  766. X
  767. X#define mask     KeyPressMask | ButtonPressMask | ButtonReleaseMask | \
  768. X        StructureNotifyMask
  769. X
  770. X        if (cur % REDRAW_EVERY == 0)
  771. X            getStick (c, u);
  772. X
  773. X        while (XCheckWindowEvent (u->dpy, u->win, mask, &ev) == True) {
  774. X
  775. X            switch (ev.type) {
  776. X
  777. X            case KeyPress:
  778. X                if (doKeyEvent (c, u, &ev, player) < 0)
  779. X                    return;
  780. X                break;
  781. X
  782. X            case ButtonPress:
  783. X                if (doButtonEvent (c, u, &ev, player) < 0)
  784. X                    return;
  785. X                break;
  786. X
  787. X            case ButtonRelease:
  788. X                if (doButtonReleaseEvent (c, u, &ev, player) < 0)
  789. X                    return;
  790. X                break;
  791. X
  792. X            case ConfigureNotify:
  793. X                scale = (double) ev.xconfigure.height /
  794. X                    (double) FS_WINDOW_HEIGHT;
  795. X                u->width = ev.xconfigure.width;
  796. X                u->height = ev.xconfigure.height;
  797. X                u->height = u->height * VIEW_WINDOW_HEIGHT /
  798. X                    FS_WINDOW_HEIGHT;
  799. X                u->xCenter = u->width / 2;
  800. X                u->yCenter = u->height / 2;
  801. X                VResizeViewport (u->v, 12.0*25.4/1000.0,
  802. X                    0.40, scale, u->width, u->height);
  803. X                break;
  804. X
  805. X            default:
  806. X                break;
  807. X            }
  808. X
  809. X        }
  810. X
  811. X        player = 0;
  812. X
  813. X    }
  814. X}
  815. X
  816. Xint doButtonEvent (c, u, ev, player)
  817. Xcraft    *c;
  818. Xviewer    *u;
  819. XXEvent    *ev;
  820. Xint    player; {
  821. X
  822. X    if (ev->xbutton.button == Button2)
  823. X        fireWeapon (c);
  824. X
  825. X    else if (ev->xbutton.button == Button3)
  826. X        selectWeapon (c);
  827. X
  828. X    return 0;
  829. X}
  830. X
  831. Xint doButtonReleaseEvent (c, u, ev, player)
  832. Xcraft    *c;
  833. Xviewer    *u;
  834. XXEvent    *ev;
  835. Xint    player; {
  836. X
  837. X    if (ev->xbutton.button == Button2)
  838. X        ceaseFireWeapon (c);
  839. X
  840. X    return 0;
  841. X}
  842. X
  843. Xint doKeyEvent (c, u, ev, player)
  844. Xcraft    *c;
  845. Xviewer    *u;
  846. XXEvent    *ev;
  847. Xint    player; 
  848. X{
  849. X
  850. X    KeySym        keysym;
  851. X    XComposeStatus    compose;
  852. X    char        buffer[MAX_MAPPED_STRING_LEN];
  853. X    int        buflen = MAX_MAPPED_STRING_LEN;
  854. X    int        count;
  855. X
  856. X    count = XLookupString (ev, buffer, buflen, &keysym, &compose);
  857. X
  858. X    if (player) {
  859. X
  860. X        switch (keysym) {
  861. X
  862. X        case XK_Left:
  863. X            if (c->flags & FL_NWS) {
  864. X                c->curNWDef = c->curNWDef - c->cinfo->NWIncr;
  865. X                if (c->curNWDef < - c->cinfo->maxNWDef)
  866. X                    c->curNWDef = - c->cinfo->maxNWDef;
  867. X            }
  868. X            else {
  869. X                c->Sa =  c->Sa - 0.05;
  870. X            }
  871. X            break;
  872. X
  873. X        case XK_Right:
  874. X            if (c->flags & FL_NWS) {
  875. X                c->curNWDef = c->curNWDef + c->cinfo->NWIncr;
  876. X                if (c->curNWDef > c->cinfo->maxNWDef)
  877. X                    c->curNWDef = c->cinfo->maxNWDef;
  878. X            }
  879. X            else {
  880. X                c->Sa = c->Sa + 0.05;
  881. X            }
  882. X            break;
  883. X
  884. X        case XK_Up:
  885. X            c->Se = c->Se - 0.01;
  886. X            break;
  887. X
  888. X        case XK_Down:
  889. X            c->Se = c->Se + 0.01;
  890. X            break;
  891. X
  892. X        case XK_Home:
  893. X            c->Se = 0.0;
  894. X            c->Sr = 0.0;
  895. X            c->Sa = 0.0;
  896. X            break;
  897. X
  898. X        case XK_y:
  899. X        case XK_Y:
  900. X            flapsUp (c);
  901. X            break;
  902. X
  903. X        case XK_h:
  904. X        case XK_H:
  905. X            flapsDown (c);
  906. X            break;
  907. X
  908. X        case XK_w:
  909. X        case XK_W:
  910. X            speedBrakeRetract (c);
  911. X            break;
  912. X
  913. X        case XK_s:
  914. X        case XK_S:
  915. X            speedBrakeExtend (c);
  916. X            break;
  917. X
  918. X        case XK_2:
  919. X        case XK_KP_Subtract:
  920. X            c->throttle = (c->throttle <= 1000) ? 1000 :
  921. X                c->throttle - 512;
  922. X            c->curThrust = calcThrust(c);
  923. X            break;
  924. X
  925. X        case XK_3:
  926. X        case XK_KP_Add:
  927. X            c->throttle = (c->throttle >= 32768) ? 32768 :
  928. X                c->throttle + 512;
  929. X            c->curThrust = calcThrust(c);
  930. X            break;
  931. X
  932. X        case XK_4:
  933. X        case XK_Prior:
  934. X            c->throttle = 32768;
  935. X            c->curThrust = calcThrust(c);
  936. X            break;
  937. X
  938. X        case XK_1:
  939. X        case XK_Next:
  940. X            c->throttle = 3276;
  941. X            c->curThrust = calcThrust(c);
  942. X            break;
  943. X
  944. X        case XK_A:
  945. X        case XK_a:
  946. X            c->flags ^= FL_AFTERBURNER;
  947. X            c->curThrust = calcThrust(c);
  948. X            break;
  949. X
  950. X        case XK_B:
  951. X        case XK_b:
  952. X            c->flags ^= FL_BRAKES;
  953. X            break;
  954. X
  955. X        case XK_L:
  956. X        case XK_l:
  957. X            newDrone (c);
  958. X            break;
  959. X
  960. X        case XK_KP_8:
  961. X            c->viewDirection.x = 1.0;
  962. X            c->viewDirection.y = 0.0;
  963. X            c->viewDirection.z = 0.0;
  964. X            c->viewUp.x = 0.0;
  965. X            c->viewUp.y = 0.0;
  966. X            c->viewUp.z = -1.0;
  967. X            break;
  968. X
  969. X/* look right */
  970. X
  971. X        case XK_KP_6:
  972. X            c->viewDirection.x = 0.0;
  973. X            c->viewDirection.y = 1.0;
  974. X            c->viewDirection.z = 0.0;
  975. X            c->viewUp.x = 0.0;
  976. X            c->viewUp.y = 0.0;
  977. X            c->viewUp.z = -1.0;
  978. X            break;
  979. X
  980. X/* look left */
  981. X
  982. X        case XK_KP_4:
  983. X            c->viewDirection.x = 0.0;
  984. X            c->viewDirection.y = -1.0;
  985. X            c->viewDirection.z = 0.0;
  986. X            c->viewUp.x = 0.0;
  987. X            c->viewUp.y = 0.0;
  988. X            c->viewUp.z = -1.0;
  989. X            break;
  990. X
  991. X/* look back */
  992. X
  993. X        case XK_KP_2:
  994. X            c->viewDirection.x = -1.0;
  995. X            c->viewDirection.y = 0.0;
  996. X            c->viewDirection.z = 0.0;
  997. X            c->viewUp.x = 0.0;
  998. X            c->viewUp.y = 0.0;
  999. X            c->viewUp.z = -1.0;
  1000. X            break;
  1001. X
  1002. X/* look up */
  1003. X
  1004. X        case XK_KP_5:
  1005. X            c->viewDirection.x = 0.0;
  1006. X            c->viewDirection.y = 0.0;
  1007. X            c->viewDirection.z = -1.0;
  1008. X            c->viewUp.x = -1.0;
  1009. X            c->viewUp.y = 0.0;
  1010. X            c->viewUp.z = 0.0;
  1011. X            break;
  1012. X
  1013. X        case XK_Q:
  1014. X        case XK_q:
  1015. X            c->curRadarTarget = getRadarTarget (c, 1);
  1016. X            break;
  1017. X
  1018. X        case XK_R:
  1019. X        case XK_r:
  1020. X            c->radarMode = (c->radarMode == RM_STANDBY) ?
  1021. X                RM_NORMAL : RM_STANDBY;
  1022. X            break;
  1023. X
  1024. X        case XK_P:
  1025. X        case XK_p:
  1026. X            killPlayer (c);
  1027. X            return -1;
  1028. X        }
  1029. X
  1030. X    }
  1031. X
  1032. X    return 0;
  1033. X}
  1034. *-*-END-of-./fsim/doEvents.c-*-*
  1035. echo x - ./fsim/doScale.c
  1036. sed 's/^X//' >./fsim/doScale.c <<'*-*-END-of-./fsim/doScale.c-*-*'
  1037. X#include <X11/Xlib.h>
  1038. X#include "scale.h"
  1039. X
  1040. Xstatic char *skipBlanks (s)
  1041. Xchar *s; {
  1042. X
  1043. X    for (; *s == ' '; s++) ;
  1044. X    return s;
  1045. X}
  1046. X
  1047. Xvoid doScale (dpy, win, gc, s, value, fth, ftw)
  1048. XDisplay        *dpy;
  1049. XWindow        win;
  1050. XGC        gc;
  1051. XscaleControl    *s;
  1052. Xdouble        value;
  1053. Xint        fth;
  1054. Xint        ftw; {
  1055. X
  1056. X    XPoint        p;
  1057. X    XSegment    seg[32];
  1058. X    int        is = 0;
  1059. X    double        vStart;
  1060. X    int        top = s->yorg - s->length;
  1061. X    int        y, w, v, n;
  1062. X    int        ytick = (double) s->minorInterval / s->scale + 0.5;
  1063. X    int        doMajor;
  1064. X    char        str[16], *q;
  1065. X
  1066. X    vStart = value - (double) (s->length / 2) * s->scale;
  1067. X    n = (int) vStart % s->minorInterval;
  1068. X    if (n > 0)
  1069. X        n = n - s->minorInterval;
  1070. X    y = s->yorg + (int) (n / s->scale);
  1071. X    if (vStart > 0.0)
  1072. X        v = (int) (vStart + s->minorInterval - 1.0);
  1073. X    else
  1074. X        v = (int) vStart;
  1075. X    v = v / s->minorInterval * s->minorInterval;
  1076. X
  1077. X/*
  1078. X *  Draw the index mark
  1079. X */
  1080. X
  1081. X    seg[is].y1 = seg[is].y2 = s->yorg - ((double) s->length / 2.0);
  1082. X    if (s->orientation & orientRight) {
  1083. X        seg[is].x1 = s->xorg - 2;
  1084. X        seg[is].x2 = seg[is].x1 - s->indexSize;
  1085. X    }
  1086. X    else {
  1087. X        seg[is].x1 = s->xorg + 2;
  1088. X        seg[is].x2 = seg[is].x1 + s->indexSize;
  1089. X    }
  1090. X    ++ is;
  1091. X
  1092. X/*
  1093. X *  step through the doMajor and minor ticks
  1094. X */
  1095. X
  1096. X    for (; y > top; (y -= ytick, v += s->minorInterval)) {
  1097. X
  1098. X/*  we don't mark negative ticks */
  1099. X
  1100. X        if (v < 0)
  1101. X            continue;
  1102. X
  1103. X        seg[is].x1 = s->xorg;
  1104. X        seg[is].y1 = seg[is].y2 = p.y = y;
  1105. X
  1106. X        if ((v % s->majorInterval) == 0) {
  1107. X            doMajor = 1;
  1108. X            w = s->majorSize;
  1109. X            if (s->orientation & orientRight)
  1110. X                seg[is].x2 = s->xorg + w;
  1111. X            else
  1112. X                seg[is].x2 = s->xorg - w;
  1113. X            sprintf (str, s->format, (double) v / s->divisor);
  1114. X            q = skipBlanks (str);
  1115. X            p.y += 0.30 * (double) fth;
  1116. X            if (s->orientation & orientRight) {
  1117. X                p.x = seg[is].x2 + 3;
  1118. X            }
  1119. X            else {
  1120. X                p.x = seg[is].x2 - 3 - ftw * strlen(q);
  1121. X            }
  1122. X        }
  1123. X        else {
  1124. X            doMajor = 0;
  1125. X            w = s->minorSize;
  1126. X            if (s->orientation & orientRight)
  1127. X                seg[is].x2 = s->xorg + w;
  1128. X            else
  1129. X                seg[is].x2 = s->xorg - w;
  1130. X        }
  1131. X
  1132. X        if (doMajor)
  1133. X            XDrawString (dpy, win, gc, p.x, p.y, q,
  1134. X                strlen (q));
  1135. X        ++ is;     
  1136. X    }
  1137. X
  1138. X    XDrawSegments (dpy, win, gc, seg, is);
  1139. X
  1140. X}
  1141. X
  1142. Xvoid doCompassScale (dpy, win, gc, s, value, fth, ftw)
  1143. XDisplay        *dpy;
  1144. XWindow        win;
  1145. XGC        gc;
  1146. XscaleControl    *s;
  1147. Xdouble        value;
  1148. Xint        fth;
  1149. Xint        ftw; {
  1150. X
  1151. X    XPoint        p;
  1152. X    XSegment    seg[32];
  1153. X    int        is = 0;
  1154. X    double        vStart;
  1155. X    int        top = s->xorg + s->length;
  1156. X    int        x, w, v, n;
  1157. X    int        xtick = (double) s->minorInterval / s->scale + 0.5;
  1158. X    int        doMajor;
  1159. X    char        str[16], *q;
  1160. X
  1161. X    vStart = value - (double) (s->length / 2) * s->scale;
  1162. X    if (vStart <= 0.0)
  1163. X        vStart += 36000.0;
  1164. X    n = (int) vStart % s->minorInterval;
  1165. X    if (n > 0)
  1166. X        n = n - s->minorInterval;
  1167. X    x = s->xorg - (int) (n / s->scale);
  1168. X    if (vStart > 0.0)
  1169. X        v = (int) (vStart + s->minorInterval - 1.0);
  1170. X    else
  1171. X        v = (int) vStart;
  1172. X    v = v / s->minorInterval * s->minorInterval;
  1173. X
  1174. X/*
  1175. X *  Draw the index mark
  1176. X */
  1177. X
  1178. X    seg[is].x1 = seg[is].x2 = s->xorg + (int) ((double) s->length / 2.0 + 0.5);
  1179. X    if (s->orientation & orientRight) {
  1180. X        seg[is].y1 = s->yorg - 2;
  1181. X        seg[is].y2 = seg[is].y1 - s->indexSize;
  1182. X    }
  1183. X    else {
  1184. X        seg[is].y1 = s->yorg + 2;
  1185. X        seg[is].y2 = seg[is].y1 + s->indexSize;
  1186. X    }
  1187. X    ++ is;
  1188. X
  1189. X/*
  1190. X *  step through the doMajor and minor ticks
  1191. X */
  1192. X
  1193. X    for (; x < top; (x += xtick, v += s->minorInterval)) {
  1194. X
  1195. X        if (v > 36000)
  1196. X            v -= 36000;
  1197. X
  1198. X        seg[is].y1 = s->yorg;
  1199. X        seg[is].x1 = seg[is].x2 = p.x = x;
  1200. X
  1201. X        if ((v % s->majorInterval) == 0) {
  1202. X            doMajor = 1;
  1203. X            w = s->majorSize;
  1204. X            if (s->orientation & orientRight)
  1205. X                seg[is].y2 = s->yorg + w;
  1206. X            else
  1207. X                seg[is].y2 = s->yorg - w;
  1208. X            sprintf (str, s->format, (double) v / s->divisor);
  1209. X            q = skipBlanks (str);
  1210. X            p.x -= (strlen(q) * ftw) / 2;
  1211. X            if (s->orientation & orientRight) {
  1212. X                p.y = seg[is].y2 + 3 + fth;
  1213. X            }
  1214. X            else {
  1215. X                p.y = seg[is].y2 - 3;
  1216. X            }
  1217. X        }
  1218. X        else {
  1219. X            doMajor = 0;
  1220. X            w = s->minorSize;
  1221. X            if (s->orientation & orientRight)
  1222. X                seg[is].y2 = s->yorg + w;
  1223. X            else
  1224. X                seg[is].y2 = s->yorg - w;
  1225. X        }
  1226. X
  1227. X        if (doMajor)
  1228. X            XDrawString (dpy, win, gc, p.x, p.y, q,
  1229. X                strlen (q));
  1230. X        ++ is;     
  1231. X    }
  1232. X
  1233. X    XDrawSegments (dpy, win, gc, seg, is);
  1234. X
  1235. X}
  1236. *-*-END-of-./fsim/doScale.c-*-*
  1237. echo x - ./fsim/rwy
  1238. sed 's/^X//' >./fsim/rwy <<'*-*-END-of-./fsim/rwy-*-*'
  1239. X*runway-with-lines
  1240. X216 54
  1241. X1 0.000000 -75.000000 0.000000
  1242. X2 12000.000000 -75.000000 0.000000
  1243. X3 12000.000000 75.000000 0.000000
  1244. X4 0.000000 75.000000 0.000000
  1245. X5 0.000000 -75.000000 0.000000
  1246. X6 12000.000000 -75.000000 0.000000
  1247. X7 12000.000000 -72.000000 0.000000
  1248. X8 0.000000 -72.000000 0.000000
  1249. X9 0.000000 75.000000 0.000000
  1250. X10 12000.000000 75.000000 0.000000
  1251. X11 12000.000000 72.000000 0.000000
  1252. X12 0.000000 72.000000 0.000000
  1253. X13 1000.000000 -68.000000 0.000000
  1254. X14 1125.000000 -68.000000 0.000000
  1255. X15 1125.000000 -45.500000 0.000000
  1256. X16 1000.000000 -45.500000 0.000000
  1257. X17 1000.000000 68.000000 0.000000
  1258. X18 1125.000000 68.000000 0.000000
  1259. X19 1125.000000 45.500000 0.000000
  1260. X20 1000.000000 45.500000 0.000000
  1261. X21 11000.000000 -68.000000 0.000000
  1262. X22 10875.000000 -68.000000 0.000000
  1263. X23 10875.000000 -45.500000 0.000000
  1264. X24 11000.000000 -45.500000 0.000000
  1265. X25 11000.000000 68.000000 0.000000
  1266. X26 10875.000000 68.000000 0.000000
  1267. X27 10875.000000 45.500000 0.000000
  1268. X28 11000.000000 45.500000 0.000000
  1269. X29 4.000000 -68.000000 0.000000
  1270. X30 129.000000 -68.000000 0.000000
  1271. X31 129.000000 -56.444443 0.000000
  1272. X32 4.000000 -56.444443 0.000000
  1273. X33 4.000000 -52.444443 0.000000
  1274. X34 129.000000 -52.444443 0.000000
  1275. X35 129.000000 -40.888889 0.000000
  1276. X36 4.000000 -40.888889 0.000000
  1277. X37 4.000000 -36.888889 0.000000
  1278. X38 129.000000 -36.888889 0.000000
  1279. X39 129.000000 -25.333334 0.000000
  1280. X40 4.000000 -25.333334 0.000000
  1281. X41 4.000000 -21.333334 0.000000
  1282. X42 129.000000 -21.333334 0.000000
  1283. X43 129.000000 -9.777778 0.000000
  1284. X44 4.000000 -9.777778 0.000000
  1285. X45 4.000000 9.777778 0.000000
  1286. X46 129.000000 9.777778 0.000000
  1287. X47 129.000000 21.333334 0.000000
  1288. X48 4.000000 21.333334 0.000000
  1289. X49 4.000000 25.333334 0.000000
  1290. X50 129.000000 25.333334 0.000000
  1291. X51 129.000000 36.888889 0.000000
  1292. X52 4.000000 36.888889 0.000000
  1293. X53 4.000000 40.888889 0.000000
  1294. X54 129.000000 40.888889 0.000000
  1295. X55 129.000000 52.444443 0.000000
  1296. X56 4.000000 52.444443 0.000000
  1297. X57 4.000000 56.444443 0.000000
  1298. X58 129.000000 56.444443 0.000000
  1299. X59 129.000000 68.000000 0.000000
  1300. X60 4.000000 68.000000 0.000000
  1301. X61 11996.000000 -68.000000 0.000000
  1302. X62 11871.000000 -68.000000 0.000000
  1303. X63 11871.000000 -56.444443 0.000000
  1304. X64 11996.000000 -56.444443 0.000000
  1305. X65 11996.000000 -52.444443 0.000000
  1306. X66 11871.000000 -52.444443 0.000000
  1307. X67 11871.000000 -40.888889 0.000000
  1308. X68 11996.000000 -40.888889 0.000000
  1309. X69 11996.000000 -36.888889 0.000000
  1310. X70 11871.000000 -36.888889 0.000000
  1311. X71 11871.000000 -25.333334 0.000000
  1312. X72 11996.000000 -25.333334 0.000000
  1313. X73 11996.000000 -21.333334 0.000000
  1314. X74 11871.000000 -21.333334 0.000000
  1315. X75 11871.000000 -9.777778 0.000000
  1316. X76 11996.000000 -9.777778 0.000000
  1317. X77 11996.000000 9.777778 0.000000
  1318. X78 11871.000000 9.777778 0.000000
  1319. X79 11871.000000 21.333334 0.000000
  1320. X80 11996.000000 21.333334 0.000000
  1321. X81 11996.000000 25.333334 0.000000
  1322. X82 11871.000000 25.333334 0.000000
  1323. X83 11871.000000 36.888889 0.000000
  1324. X84 11996.000000 36.888889 0.000000
  1325. X85 11996.000000 40.888889 0.000000
  1326. X86 11871.000000 40.888889 0.000000
  1327. X87 11871.000000 52.444443 0.000000
  1328. X88 11996.000000 52.444443 0.000000
  1329. X89 11996.000000 56.444443 0.000000
  1330. X90 11871.000000 56.444443 0.000000
  1331. X91 11871.000000 68.000000 0.000000
  1332. X92 11996.000000 68.000000 0.000000
  1333. X93 258.000000 -2.000000 0.000000
  1334. X94 383.000000 -2.000000 0.000000
  1335. X95 383.000000 2.000000 0.000000
  1336. X96 258.000000 2.000000 0.000000
  1337. X97 633.000000 -2.000000 0.000000
  1338. X98 758.000000 -2.000000 0.000000
  1339. X99 758.000000 2.000000 0.000000
  1340. X100 633.000000 2.000000 0.000000
  1341. X101 1008.000000 -2.000000 0.000000
  1342. X102 1133.000000 -2.000000 0.000000
  1343. X103 1133.000000 2.000000 0.000000
  1344. X104 1008.000000 2.000000 0.000000
  1345. X105 1383.000000 -2.000000 0.000000
  1346. X106 1508.000000 -2.000000 0.000000
  1347. X107 1508.000000 2.000000 0.000000
  1348. X108 1383.000000 2.000000 0.000000
  1349. X109 1758.000000 -2.000000 0.000000
  1350. X110 1883.000000 -2.000000 0.000000
  1351. X111 1883.000000 2.000000 0.000000
  1352. X112 1758.000000 2.000000 0.000000
  1353. X113 2133.000000 -2.000000 0.000000
  1354. X114 2258.000000 -2.000000 0.000000
  1355. X115 2258.000000 2.000000 0.000000
  1356. X116 2133.000000 2.000000 0.000000
  1357. X117 2508.000000 -2.000000 0.000000
  1358. X118 2633.000000 -2.000000 0.000000
  1359. X119 2633.000000 2.000000 0.000000
  1360. X120 2508.000000 2.000000 0.000000
  1361. X121 2883.000000 -2.000000 0.000000
  1362. X122 3008.000000 -2.000000 0.000000
  1363. X123 3008.000000 2.000000 0.000000
  1364. X124 2883.000000 2.000000 0.000000
  1365. X125 3258.000000 -2.000000 0.000000
  1366. X126 3383.000000 -2.000000 0.000000
  1367. X127 3383.000000 2.000000 0.000000
  1368. X128 3258.000000 2.000000 0.000000
  1369. X129 3633.000000 -2.000000 0.000000
  1370. X130 3758.000000 -2.000000 0.000000
  1371. X131 3758.000000 2.000000 0.000000
  1372. X132 3633.000000 2.000000 0.000000
  1373. X133 4008.000000 -2.000000 0.000000
  1374. X134 4133.000000 -2.000000 0.000000
  1375. X135 4133.000000 2.000000 0.000000
  1376. X136 4008.000000 2.000000 0.000000
  1377. X137 4383.000000 -2.000000 0.000000
  1378. X138 4508.000000 -2.000000 0.000000
  1379. X139 4508.000000 2.000000 0.000000
  1380. X140 4383.000000 2.000000 0.000000
  1381. X141 4758.000000 -2.000000 0.000000
  1382. X142 4883.000000 -2.000000 0.000000
  1383. X143 4883.000000 2.000000 0.000000
  1384. X144 4758.000000 2.000000 0.000000
  1385. X145 5133.000000 -2.000000 0.000000
  1386. X146 5258.000000 -2.000000 0.000000
  1387. X147 5258.000000 2.000000 0.000000
  1388. X148 5133.000000 2.000000 0.000000
  1389. X149 5508.000000 -2.000000 0.000000
  1390. X150 5633.000000 -2.000000 0.000000
  1391. X151 5633.000000 2.000000 0.000000
  1392. X152 5508.000000 2.000000 0.000000
  1393. X153 5883.000000 -2.000000 0.000000
  1394. X154 6008.000000 -2.000000 0.000000
  1395. X155 6008.000000 2.000000 0.000000
  1396. X156 5883.000000 2.000000 0.000000
  1397. X157 6258.000000 -2.000000 0.000000
  1398. X158 6383.000000 -2.000000 0.000000
  1399. X159 6383.000000 2.000000 0.000000
  1400. X160 6258.000000 2.000000 0.000000
  1401. X161 6633.000000 -2.000000 0.000000
  1402. X162 6758.000000 -2.000000 0.000000
  1403. X163 6758.000000 2.000000 0.000000
  1404. X164 6633.000000 2.000000 0.000000
  1405. X165 7008.000000 -2.000000 0.000000
  1406. X166 7133.000000 -2.000000 0.000000
  1407. X167 7133.000000 2.000000 0.000000
  1408. X168 7008.000000 2.000000 0.000000
  1409. X169 7383.000000 -2.000000 0.000000
  1410. X170 7508.000000 -2.000000 0.000000
  1411. X171 7508.000000 2.000000 0.000000
  1412. X172 7383.000000 2.000000 0.000000
  1413. X173 7758.000000 -2.000000 0.000000
  1414. X174 7883.000000 -2.000000 0.000000
  1415. X175 7883.000000 2.000000 0.000000
  1416. X176 7758.000000 2.000000 0.000000
  1417. X177 8133.000000 -2.000000 0.000000
  1418. X178 8258.000000 -2.000000 0.000000
  1419. X179 8258.000000 2.000000 0.000000
  1420. X180 8133.000000 2.000000 0.000000
  1421. X181 8508.000000 -2.000000 0.000000
  1422. X182 8633.000000 -2.000000 0.000000
  1423. X183 8633.000000 2.000000 0.000000
  1424. X184 8508.000000 2.000000 0.000000
  1425. X185 8883.000000 -2.000000 0.000000
  1426. X186 9008.000000 -2.000000 0.000000
  1427. X187 9008.000000 2.000000 0.000000
  1428. X188 8883.000000 2.000000 0.000000
  1429. X189 9258.000000 -2.000000 0.000000
  1430. X190 9383.000000 -2.000000 0.000000
  1431. X191 9383.000000 2.000000 0.000000
  1432. X192 9258.000000 2.000000 0.000000
  1433. X193 9633.000000 -2.000000 0.000000
  1434. X194 9758.000000 -2.000000 0.000000
  1435. X195 9758.000000 2.000000 0.000000
  1436. X196 9633.000000 2.000000 0.000000
  1437. X197 10008.000000 -2.000000 0.000000
  1438. X198 10133.000000 -2.000000 0.000000
  1439. X199 10133.000000 2.000000 0.000000
  1440. X200 10008.000000 2.000000 0.000000
  1441. X201 10383.000000 -2.000000 0.000000
  1442. X202 10508.000000 -2.000000 0.000000
  1443. X203 10508.000000 2.000000 0.000000
  1444. X204 10383.000000 2.000000 0.000000
  1445. X205 10758.000000 -2.000000 0.000000
  1446. X206 10883.000000 -2.000000 0.000000
  1447. X207 10883.000000 2.000000 0.000000
  1448. X208 10758.000000 2.000000 0.000000
  1449. X209 11133.000000 -2.000000 0.000000
  1450. X210 11258.000000 -2.000000 0.000000
  1451. X211 11258.000000 2.000000 0.000000
  1452. X212 11133.000000 2.000000 0.000000
  1453. X213 11508.000000 -2.000000 0.000000
  1454. X214 11633.000000 -2.000000 0.000000
  1455. X215 11633.000000 2.000000 0.000000
  1456. X216 11508.000000 2.000000 0.000000
  1457. X#b7b19f 4  1 2 3 4
  1458. Xwhite 4  5 6 7 8
  1459. Xwhite 4  9 10 11 12
  1460. Xwhite 4  13 14 15 16
  1461. Xwhite 4  17 18 19 20
  1462. Xwhite 4  21 22 23 24
  1463. Xwhite 4  25 26 27 28
  1464. Xwhite 4  29 30 31 32
  1465. Xwhite 4  33 34 35 36
  1466. Xwhite 4  37 38 39 40
  1467. Xwhite 4  41 42 43 44
  1468. Xwhite 4  45 46 47 48
  1469. Xwhite 4  49 50 51 52
  1470. Xwhite 4  53 54 55 56
  1471. Xwhite 4  57 58 59 60
  1472. Xwhite 4  61 62 63 64
  1473. Xwhite 4  65 66 67 68
  1474. Xwhite 4  69 70 71 72
  1475. Xwhite 4  73 74 75 76
  1476. Xwhite 4  77 78 79 80
  1477. Xwhite 4  81 82 83 84
  1478. Xwhite 4  85 86 87 88
  1479. Xwhite 4  89 90 91 92
  1480. Xwhite 4  93 94 95 96
  1481. Xwhite 4  97 98 99 100
  1482. Xwhite 4  101 102 103 104
  1483. Xwhite 4  105 106 107 108
  1484. Xwhite 4  109 110 111 112
  1485. Xwhite 4  113 114 115 116
  1486. Xwhite 4  117 118 119 120
  1487. Xwhite 4  121 122 123 124
  1488. Xwhite 4  125 126 127 128
  1489. Xwhite 4  129 130 131 132
  1490. Xwhite 4  133 134 135 136
  1491. Xwhite 4  137 138 139 140
  1492. Xwhite 4  141 142 143 144
  1493. Xwhite 4  145 146 147 148
  1494. Xwhite 4  149 150 151 152
  1495. Xwhite 4  153 154 155 156
  1496. Xwhite 4  157 158 159 160
  1497. Xwhite 4  161 162 163 164
  1498. Xwhite 4  165 166 167 168
  1499. Xwhite 4  169 170 171 172
  1500. Xwhite 4  173 174 175 176
  1501. Xwhite 4  177 178 179 180
  1502. Xwhite 4  181 182 183 184
  1503. Xwhite 4  185 186 187 188
  1504. Xwhite 4  189 190 191 192
  1505. Xwhite 4  193 194 195 196
  1506. Xwhite 4  197 198 199 200
  1507. Xwhite 4  201 202 203 204
  1508. Xwhite 4  205 206 207 208
  1509. Xwhite 4  209 210 211 212
  1510. Xwhite 4  213 214 215 216
  1511. *-*-END-of-./fsim/rwy-*-*
  1512. echo x - ./fsim/mig23
  1513. sed 's/^X//' >./fsim/mig23 <<'*-*-END-of-./fsim/mig23-*-*'
  1514. Xmig-23-wings-swept
  1515. X88 10
  1516. X1 36.5891 0 0
  1517. X2 34.4368 0.86092 0
  1518. X3 30.9931 1.29138 0
  1519. X4 27.119 1.72184 0
  1520. X5 20.6621 1.72184 0
  1521. X6 18.9402 2.1523 0
  1522. X7 14.2052 3.01322 0
  1523. X8 -3.44368 2.58276 0
  1524. X9 -9.03966 2.1523 0
  1525. X10 -16.7879 0.86092 0
  1526. X11 -18.0793 0.43046 0
  1527. X12 -18.0793 0 0
  1528. X13 36.5891 0 0
  1529. X14 34.4368 -0.86092 0
  1530. X15 30.9931 -1.29138 0
  1531. X16 27.119 -1.72184 0
  1532. X17 20.6621 -1.72184 0
  1533. X18 18.9402 -2.1523 0
  1534. X19 14.2052 -3.01322 0
  1535. X20 -3.44368 -2.58276 0
  1536. X21 -9.03966 -2.1523 0
  1537. X22 -16.7879 -0.86092 0
  1538. X23 -18.0793 -0.43046 0
  1539. X24 -18.0793 0 0
  1540. X25 14.2052 3.01322 -3.01322
  1541. X26 4.73506 7.31782 -3.01322
  1542. X27 6.02644 8.6092 -3.01322
  1543. X28 -11.192 13.7747 -3.01322
  1544. X29 -12.0529 13.7747 -3.01322
  1545. X30 -14.2052 11.192 -3.01322
  1546. X31 -14.2052 10.7615 -3.01322
  1547. X32 -3.44368 2.58276 -3.01322
  1548. X33 14.2052 -3.01322 -3.01322
  1549. X34 4.73506 -7.31782 -3.01322
  1550. X35 6.02644 -8.6092 -3.01322
  1551. X36 -11.192 -13.7747 -3.01322
  1552. X37 -12.0529 -13.7747 -3.01322
  1553. X38 -14.2052 -11.192 -3.01322
  1554. X39 -14.2052 -10.7615 -3.01322
  1555. X40 -3.44368 -2.58276 -3.01322
  1556. X41 -18.9402 3.01322 -1.72184
  1557. X42 -20.2316 7.31782 -1.72184
  1558. X43 -18.5098 8.6092 -1.72184
  1559. X44 -9.03966 2.1523 -1.72184
  1560. X45 -16.7879 0.86092 -1.72184
  1561. X46 -18.9402 -3.01322 -1.72184
  1562. X47 -20.2316 -7.31782 -1.72184
  1563. X48 -18.5098 -8.6092 -1.72184
  1564. X49 -9.03966 -2.1523 -1.72184
  1565. X50 -16.7879 -0.86092 -1.72184
  1566. X51 36.5891 0 0
  1567. X52 33.1454 0 -1.29138
  1568. X53 30.1322 0 -2.1523
  1569. X54 25.8276 0 -2.58276
  1570. X55 22.3839 0 -3.87414
  1571. X56 18.0793 0 -4.3046
  1572. X57 9.47012 0 -3.87414
  1573. X58 -0.860918 0 -3.44368
  1574. X59 -8.6092 0 -6.02644
  1575. X60 -16.3575 0 -10.331
  1576. X61 -18.9402 0 -9.03966
  1577. X62 -18.0793 0 -3.87414
  1578. X63 -19.8012 0 -3.44368
  1579. X64 -17.2184 0 -1.72184
  1580. X65 -18.0793 0 -1.72184
  1581. X66 -18.0793 0 1.29138
  1582. X67 -15.4966 0 1.72184
  1583. X68 -6.4569 0 2.1523
  1584. X69 10.331 0 2.1523
  1585. X70 20.2316 0 1.72184
  1586. X71 28.8408 0 1.29138
  1587. X72 33.1454 0 0.86092
  1588. X73 -15.4966 0 1.72184
  1589. X74 -15.4966 0 4.3046
  1590. X75 -13.3443 0 5.16552
  1591. X76 -6.4569 0 2.1523
  1592. X77 20.6621 1.72184 -3.01322
  1593. X78 18.9402 2.1523 -3.01322
  1594. X79 14.2052 3.01322 -3.01322
  1595. X80 -3.44368 2.58276 -3.01322
  1596. X81 -3.44368 -2.58276 -3.01322
  1597. X82 14.2052 -3.01322 -3.01322
  1598. X83 18.9402 -2.1523 -3.01322
  1599. X84 20.6621 -1.72184 -3.01322
  1600. X85 -3.44368 2.58276 -3.01322
  1601. X86 -16.7879 0.86092 -1.72184
  1602. X87 -16.7879 -0.86092 -1.72184
  1603. X88 -3.44368 -2.58276 -3.01322
  1604. Xgray33 12 1 2 3 4 5 6 7 8 9 10 11 12
  1605. Xgray33 12 13 14 15 16 17 18 19 20 21 22 23 24
  1606. Xgray33 8 25 26 27 28 29 30 31 32
  1607. Xgray33 8 33 34 35 36 37 38 39 40
  1608. Xgray33 5 41 42 43 44 45
  1609. Xgray33 5 46 47 48 49 50
  1610. Xgray33 22 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  1611. Xgray33 4 73 74 75 76
  1612. Xgray33 8 77 78 79 80 81 82 83 84
  1613. Xgray33 4 85 86 87 88
  1614. *-*-END-of-./fsim/mig23-*-*
  1615. echo x - ./fsim/f16
  1616. sed 's/^X//' >./fsim/f16 <<'*-*-END-of-./fsim/f16-*-*'
  1617. XF-16-fighter
  1618. X130 12
  1619. X1 -18.165 0 0
  1620. X2 -18.165 -1.191 0
  1621. X3 -15.187 -2.085 0
  1622. X4 -13.698 -2.382 0
  1623. X5 -17.272 -2.382 0
  1624. X6 -17.272 -3.573 0
  1625. X7 -10.923 -3.573 0
  1626. X8 -4.169 -3.573 0
  1627. X9 -4.169 -4.765 0
  1628. X10 5.598 -4.765 0
  1629. X11 18.463 -2.144 0
  1630. X12 18.939 -1.787 0
  1631. X13 22.274 -1.489 0
  1632. X14 24.895 -1.191 0
  1633. X15 27.992 0 0
  1634. X16 -6.551 -3.573 0
  1635. X17 -6.551 -15.485 0
  1636. X18 0.357 -15.485 0
  1637. X19 0.357 -15.187 0
  1638. X20 -2.978 -15.008 0
  1639. X21 5.598 -4.765 0
  1640. X22 -4.169 -4.765 0
  1641. X23 -4.169 -3.573 0
  1642. X24 -17.272 -3.573 0
  1643. X25 -17.272 -8.934 0.893
  1644. X26 -15.187 -8.934 0.893
  1645. X27 -10.923 -3.573 0
  1646. X28 27.992 0 0
  1647. X29 24.895 1.191 0
  1648. X30 22.274 1.489 0
  1649. X31 18.939 1.787 0
  1650. X32 18.463 2.144 0
  1651. X33 5.598 4.765 0
  1652. X34 -4.169 4.765 0
  1653. X35 -4.169 3.573 0
  1654. X36 -10.923 3.573 0
  1655. X37 -17.272 3.573 0
  1656. X38 -17.272 2.382 0
  1657. X39 -13.698 2.382 0
  1658. X40 -15.187 2.085 0
  1659. X41 -18.165 1.191 0
  1660. X42 -18.165 0 0
  1661. X43 5.598 4.765 0
  1662. X44 -2.978 15.008 0
  1663. X45 0.357 15.187 0
  1664. X46 0.357 15.485 0
  1665. X47 -6.551 15.485 0
  1666. X48 -6.551 3.573 0
  1667. X49 -4.169 3.573 0
  1668. X50 -4.169 4.765 0
  1669. X51 -10.923 3.573 0
  1670. X52 -15.187 8.934 0.893
  1671. X53 -17.272 8.934 0.893
  1672. X54 -17.272 3.573 0
  1673. X55 27.992 0 0
  1674. X56 23.525 0 -1.191
  1675. X57 17.272 0 -2.382
  1676. X58 15.783 0 -3.812
  1677. X59 13.996 0 -4.169
  1678. X60 11.316 0 -4.05
  1679. X61 8.338 0 -3.335
  1680. X62 1.787 0 -2.382
  1681. X63 -4.169 0 -2.382
  1682. X64 -13.936 0 -1.906
  1683. X65 -15.128 0 -1.906
  1684. X66 -15.187 0 -1.787
  1685. X67 -18.165 0 -1.191
  1686. X68 -18.165 0 0
  1687. X69 -4.169 0 -2.382
  1688. X70 -10.125 0 -4.05
  1689. X71 -15.783 0 -10.482
  1690. X72 -19.654 0 -10.482
  1691. X73 -19.654 0 -9.529
  1692. X74 -19.654 0 -9.529
  1693. X75 -16.378 0 -3.573
  1694. X76 -16.378 0 -2.144
  1695. X77 -14.889 0 -2.382
  1696. X78 -13.936 0 -2.382
  1697. X79 -13.936 0 -1.906
  1698. X80 -18.165 0 0
  1699. X81 -18.165 0 1.191
  1700. X82 -15.187 0 2.085
  1701. X83 -13.698 0 2.263
  1702. X84 -2.68 0 2.382
  1703. X85 8.04 0 2.382
  1704. X86 12.507 0 2.263
  1705. X87 12.507 0 0.596
  1706. X88 19.952 0 0.596
  1707. X89 23.525 0 0.476
  1708. X90 27.992 0 0
  1709. X91 -3.551 0 -2.382
  1710. X92 -3.551 -3.871 -0.10
  1711. X93 -3.551 -15.485 0
  1712. X94 -3.551 -15.485 0.1065
  1713. X95 -3.551 -3.871 0.142
  1714. X96 -3.551 -2.58 0.2556
  1715. X97 -3.551 -2.387 1.818
  1716. X98 -3.551 -2.102 2.015
  1717. X99 -3.551 -1.03 2.251
  1718. X100 -3.551 0 2.282
  1719. X101 -3.551 1.03 2.251
  1720. X102 -3.551 2.102 2.015
  1721. X103 -3.551 2.387 1.818
  1722. X104 -3.551 2.58 0.2556
  1723. X105 -3.551 3.871 0.142
  1724. X106 -3.551 15.485 0.1065
  1725. X107 -3.551 15.485 0
  1726. X108 -3.551 3.871 -0.10
  1727. X109 13.996 0 -4.169
  1728. X110 13.996 -0.8932 -3.692
  1729. X111 13.996 -1.191 -2.978
  1730. X112 13.996 -1.251 -2.502
  1731. X113 13.996 -1.787 -1.311
  1732. X114 13.996 -3.054 0
  1733. X115 13.996 -1.583 0.3568
  1734. X116 13.996 0 0.596
  1735. X117 13.996 1.583 0.3568
  1736. X118 13.996 3.054 0
  1737. X119 13.996 1.787 -1.311
  1738. X120 13.996 1.251 -2.502
  1739. X121 13.996 1.191 -2.978
  1740. X122 13.996 0.8932 -3.692
  1741. X123 -18.165 1.191 0
  1742. X124 -18.165 0.842 0.842
  1743. X125 -18.165 0 1.191
  1744. X126 -18.165 -0.842 0.842
  1745. X127 -18.165 -1.191 0
  1746. X128 -18.165 -0.842 -0.842
  1747. X129 -18.165 0 -1.191
  1748. X130 -18.165 0.842 -0.842
  1749. Xgray33 14 109 110 111 112 113 114 115 116 117 118 119 120 121 122
  1750. Xgray33 18 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
  1751. Xgray33 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  1752. Xgray33 8 16 17 18 19 20 21 22 23
  1753. Xgray33 4 24 25 26 27
  1754. Xgray33 15 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  1755. Xgray33 8 43 44 45 46 47 48 49 50
  1756. Xgray33 4 51 52 53 54
  1757. Xgray33 14 55 56 57 58 59 60 61 62 63 64 65 66 67 68
  1758. Xgray33 11 69 70 71 72 73 74 75 76 77 78 79
  1759. Xgray33 11 80 81 82 83 84 85 86 87 88 89 90
  1760. Xgray33 8 123 124 125 126 127 128 129 130
  1761. *-*-END-of-./fsim/f16-*-*
  1762. echo x - ./fsim/transpose.c
  1763. sed 's/^X//' >./fsim/transpose.c <<'*-*-END-of-./fsim/transpose.c-*-*'
  1764. X/*
  1765. X *    xflight : an aerial combat simulator for X
  1766. X *
  1767. X *    Written by Riley Rainey,  riley@mips.com
  1768. X *
  1769. X *    Permission to use, copy, modify and distribute (without charge) this
  1770. X *    software, documentation, images, etc. is granted, provided that this 
  1771. X *    comment and the author's name is retained.
  1772. X *
  1773. X */
  1774. X#include <Vlib.h>
  1775. X
  1776. Xint    transpose (m, r)
  1777. XVMatrix *m, *r; {
  1778. X
  1779. X    int    i, j;
  1780. X
  1781. X    for (i=0; i<4; ++i)
  1782. X        for (j=0; j<4; ++j)
  1783. X            r->m[i][j] = m->m[j][i];
  1784. X    return 0;
  1785. X}
  1786. *-*-END-of-./fsim/transpose.c-*-*
  1787. echo x - ./fsim/mtn
  1788. sed 's/^X//' >./fsim/mtn <<'*-*-END-of-./fsim/mtn-*-*'
  1789. X*mountain
  1790. X5 4
  1791. X1 28000 0 0
  1792. X2 0 16000 0
  1793. X3 -35000 0 0
  1794. X4 0 -14000 0
  1795. X5 0 0 -8200
  1796. X#788b63 3 1 2 5
  1797. X#788b63 3 2 3 5
  1798. X#788b63 3 3 4 5
  1799. X#788b63 3 4 1 5
  1800. *-*-END-of-./fsim/mtn-*-*
  1801. echo x - ./fsim/acm.c
  1802. sed 's/^X//' >./fsim/acm.c <<'*-*-END-of-./fsim/acm.c-*-*'
  1803. X/*
  1804. X *    xflight : an aerial combat simulator for X
  1805. X *
  1806. X *    Written by Riley Rainey,  riley@mips.com
  1807. X *
  1808. X *    Permission to use, copy, modify and distribute (without charge) this
  1809. X *    software, documentation, images, etc. is granted, provided that this 
  1810. X *    comment and the author's name is retained.
  1811. X *
  1812. X */
  1813. X#include "manifest.h"
  1814. X#include <sys/types.h>
  1815. X#include <stdio.h>
  1816. X#include <pwd.h>
  1817. X#include <signal.h>
  1818. X#include <sys/socket.h>
  1819. X#include <netinet/in.h>
  1820. X#include <netdb.h>
  1821. X#include <setjmp.h>
  1822. X
  1823. Xextern char *getenv ();
  1824. Xextern struct servent *getservent();
  1825. X
  1826. Xjmp_buf    dead;
  1827. X
  1828. Xdone () {
  1829. X    longjmp (dead);
  1830. X}
  1831. X
  1832. Xmain (argc, argv)
  1833. Xint    argc;
  1834. Xchar    *argv[]; {
  1835. X
  1836. X    char    *display;
  1837. X    char    *username;
  1838. X    char    *host;
  1839. X    char    myhost[64];
  1840. X    char    args[128];
  1841. X    int    s, n = 1;
  1842. X    struct passwd    *pwent, *getpwuid();
  1843. X    struct servent    *sp;
  1844. X    struct sockaddr_in sin;
  1845. X    struct hostent    *h = (struct hostent *) NULL;
  1846. X
  1847. X    if ((host = getenv("ACMSERVER")) == NULL)
  1848. X        if (argc >= 2) {
  1849. X            host = argv[1];
  1850. X            n = 2;
  1851. X        }
  1852. X        else {
  1853. X            fprintf (stderr, "usage: %s server-hostname\n", argv[0]);
  1854. X            exit (1);
  1855. X        }
  1856. X
  1857. X    if ((pwent = getpwuid(getuid())) == NULL) {
  1858. X        fprintf (stderr, "Yow!\n");
  1859. X        exit (1);
  1860. X    }
  1861. X
  1862. X    if ((display = getenv("DISPLAY")) == NULL) {
  1863. X        fprintf (stderr, "Excuse me, but you have no DISPLAY.\n\
  1864. XHow do you use X, anyway?\n");
  1865. X        exit (1);
  1866. X    }
  1867. X
  1868. X/*
  1869. X *  Sometimes we end up with a DISPLAY value that won't jive on the
  1870. X *  network (e.g. ":0.0") -- fix these cases.
  1871. X */
  1872. X
  1873. X    if (*display == ':') {
  1874. X        gethostname (myhost, sizeof(myhost));
  1875. X        strcat (myhost, display);
  1876. X        display = myhost;
  1877. X    }
  1878. X
  1879. X    if ((sin.sin_addr.s_addr = inet_addr (host)) != -1) {
  1880. X        sin.sin_family = AF_INET;
  1881. X    }
  1882. X    else if ((h = gethostbyname (host)) != 0) {
  1883. X        sin.sin_family = h->h_addrtype;
  1884. X        bcopy (h->h_addr, &sin.sin_addr, h->h_length);
  1885. X    }
  1886. X    else {
  1887. X        fprintf (stderr, "Unknown host \"%s\"\n", host);
  1888. X        exit (1);
  1889. X    }
  1890. X
  1891. X    sin.sin_port = htons(ACM_PORT);
  1892. X
  1893. X    signal (SIGPIPE, done);
  1894. X
  1895. X    if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
  1896. X        perror ("can't get a socket");
  1897. X        exit (1);
  1898. X    }
  1899. X
  1900. X    if (connect (s, (struct sockaddr *) &sin, sizeof (sin)) < 0) {
  1901. X        perror ("can't connect to server");
  1902. X        close (s);
  1903. X        exit (1);
  1904. X    }
  1905. X
  1906. X    if (argv[n] != (char *) NULL) 
  1907. X        strcpy (args, argv[n++]);
  1908. X    else
  1909. X        strcpy (args, "");
  1910. X
  1911. X    for (; argv[n] != (char *) NULL; ++n) {
  1912. X        strcat (args, "|");
  1913. X        strcat (args, argv[n]);
  1914. X    }
  1915. X
  1916. X    if (setjmp (dead) == 0)
  1917. X        handshake (s, display, pwent->pw_name, args);
  1918. X
  1919. X    exit (0);
  1920. X}
  1921. X
  1922. Xhandshake (s, dpy, name, args)
  1923. Xint    s;
  1924. Xchar    *dpy, *name, *args; {
  1925. X
  1926. X    char    info[128];
  1927. X    int    n;
  1928. X
  1929. X    sprintf (info, "%s %s %s\n", dpy, name, args);
  1930. X    write (s, info, strlen (info));
  1931. X    while ((n = read (s, info, sizeof (info))) > 0)
  1932. X        write (fileno (stdout), info, n);
  1933. X
  1934. X    return 0;
  1935. X}
  1936. *-*-END-of-./fsim/acm.c-*-*
  1937. echo x - ./fsim/doRadar.c
  1938. sed 's/^X//' >./fsim/doRadar.c <<'*-*-END-of-./fsim/doRadar.c-*-*'
  1939. X/*
  1940. X *    xflight : an aerial combat simulator for X
  1941. X *
  1942. X *    Written by Riley Rainey,  riley@mips.com
  1943. X *
  1944. X *    Permission to use, copy, modify and distribute (without charge) this
  1945. X *    software, documentation, images, etc. is granted, provided that this 
  1946. X *    comment and the author's name is retained.
  1947. X *
  1948. X */
  1949. X#include "pm.h"
  1950. X#include <stdio.h>
  1951. X#include <math.h>
  1952. X
  1953. X#define scanSlope     2.1445
  1954. X
  1955. Xvoid plotPrimaryTarget(), plotNormalTarget();
  1956. X
  1957. Xstatic char *thirty = "30";
  1958. X
  1959. X/*
  1960. X *  We'll build an array that contains the amount of radar radiation that each
  1961. X *  craft can "see" coming from another player.  This is used to build each players
  1962. X *  radar threat display.
  1963. X *
  1964. X *  rval[i][j] will represent the amount of radar energy that player j sees coming from
  1965. X *  player i.
  1966. X *
  1967. X *  For neatness, the rval array has been moved to the ptbl vector.
  1968. X */
  1969. X
  1970. Xchar *ItoA (n, s)
  1971. Xint    n;
  1972. Xchar    *s; {
  1973. X
  1974. X    if (abs(n) > 999) {
  1975. X        sprintf (s, "%d,%3.3d", n/1000, abs(n) % 1000);
  1976. X    }
  1977. X    else 
  1978. X        sprintf (s, "%d", n);
  1979. X}
  1980. X
  1981. Xint doRadar (c, u)
  1982. Xcraft *c;
  1983. Xviewer *u; {
  1984. X
  1985. X    register craft *p;
  1986. X    register int    i, t, x, y;
  1987. X    register int    xc, yc;
  1988. X    register double    xs, ys;
  1989. X    char        *buf;
  1990. X
  1991. X    t = c->curRadarTarget = getRadarTarget (c, 0);
  1992. X    xc = (u->radarWidth + 1) / 2;
  1993. X    yc = (u->radarHeight + 1) / 2;
  1994. X
  1995. X/*
  1996. X *  Set drawing colors and font
  1997. X */
  1998. X
  1999. X    XSetForeground (u->dpy, u->gc, u->v->pixel[blackPixel]);
  2000. X    XFillRectangle (u->dpy, u->rwin, u->gc, 0, 0,
  2001. X         u->radarWidth, u->radarHeight);
  2002. X    XSetForeground (u->dpy, u->gc, u->v->pixel[whitePixel]);
  2003. X    XSetFont (u->dpy, u->gc, u->rfont->fid);
  2004. X
  2005. X/*
  2006. X *  Draw reference "thing"
  2007. X */
  2008. X
  2009. X    XDrawLine (u->dpy, u->rwin, u->gc, xc, yc, xc - 5, yc + 5);
  2010. X    XDrawLine (u->dpy, u->rwin, u->gc, xc - 10, yc, xc - 5, yc + 5);
  2011. X    XDrawLine (u->dpy, u->rwin, u->gc, xc - 10, yc, xc - 18, yc);
  2012. X    XDrawLine (u->dpy, u->rwin, u->gc, xc, yc, xc + 5, yc + 5);
  2013. X    XDrawLine (u->dpy, u->rwin, u->gc, xc + 10, yc, xc + 5, yc + 5);
  2014. X    XDrawLine (u->dpy, u->rwin, u->gc, xc + 10, yc, xc + 18, yc);
  2015. X    XDrawLine (u->dpy, u->rwin, u->gc, 0, 0, u->radarWidth-1, 0);
  2016. X    XDrawLine (u->dpy, u->rwin, u->gc, u->radarWidth-1, 0,
  2017. X        u->radarWidth-1, u->radarHeight-1);
  2018. X    XDrawLine (u->dpy, u->rwin, u->gc, 0, u->radarHeight-1,
  2019. X        u->radarWidth-1, u->radarHeight-1);
  2020. X    XDrawLine (u->dpy, u->rwin, u->gc, 0, u->radarHeight, 0, 0);
  2021. X
  2022. X/*
  2023. X *  Radar off?
  2024. X */
  2025. X
  2026. X    if (c->radarMode <= RM_STANDBY) {
  2027. X        if (c->radarMode == RM_OFF)
  2028. X            buf = "RADAR OFF";
  2029. X        else
  2030. X            buf = "RADAR STBY";
  2031. X        c->curRadarTarget = -1;
  2032. X        XDrawString (u->dpy, u->rwin, u->gc, u->rftw * 4,
  2033. X            u->fth * 2, buf, strlen(buf));
  2034. X        return 0;
  2035. X    }
  2036. X
  2037. X/*
  2038. X *  Plot reference lines
  2039. X */
  2040. X
  2041. X    i = (u->radarWidth + 3) / 4;
  2042. X    y = u->rfth + 3;
  2043. X    XDrawLine (u->dpy, u->rwin, u->gc, xc, y, xc, y+4);
  2044. X    y = u->radarHeight - 5 - u->rfth;
  2045. X    XDrawLine (u->dpy, u->rwin, u->gc, xc, y, xc, y+4);
  2046. X
  2047. X    x = xc - i;
  2048. X    y = u->rfth + 6;
  2049. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
  2050. X    y = u->radarHeight - 6 - u->rfth;
  2051. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
  2052. X    XDrawString (u->dpy, u->rwin, u->gc, x-u->rftw, y+2+u->rfth,
  2053. X        thirty, 2);
  2054. X
  2055. X    x = xc + i;
  2056. X    y = u->rfth + 6;
  2057. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
  2058. X    y = u->radarHeight - 6 - u->rfth;
  2059. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x, y+4);
  2060. X    XDrawString (u->dpy, u->rwin, u->gc, x-u->rftw, y+2+u->rfth,
  2061. X        thirty, 2);
  2062. X
  2063. X    i = (u->radarHeight + 3) / 4;
  2064. X    x = 2;
  2065. X    XDrawLine (u->dpy, u->rwin, u->gc, x, yc, x+4, yc);
  2066. X    x = u->radarWidth - 6;
  2067. X    XDrawLine (u->dpy, u->rwin, u->gc, x, yc, x+4, yc);
  2068. X
  2069. X    x = 5 + 2 * u->rftw;
  2070. X    y = yc - i;
  2071. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
  2072. X    x = 3;
  2073. X    XDrawString (u->dpy, u->rwin, u->gc, x, y+u->rfth/3,
  2074. X        thirty, 2);
  2075. X    x = u->radarWidth - 6;
  2076. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
  2077. X
  2078. X    x = 5 + 2 * u->rftw;
  2079. X    y = yc + i;
  2080. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
  2081. X    x = 3;
  2082. X    XDrawString (u->dpy, u->rwin, u->gc, x, y+u->rfth/3,
  2083. X        thirty, 2);
  2084. X    x = u->radarWidth - 6;
  2085. X    XDrawLine (u->dpy, u->rwin, u->gc, x, y, x+4, y);
  2086. X    
  2087. X/*
  2088. X *  Now plot all targets visible to the radar system.
  2089. X */
  2090. X
  2091. X    for ((i=0, p=ptbl); i<MAXPLAYERS; (++i, ++p)) {
  2092. X        if (c->relValid[i] > 0 && c->relPos[i].x >= 0.0) {
  2093. X
  2094. X            xs = c->relPos[i].y / c->relPos[i].x / scanSlope;
  2095. X            ys = c->relPos[i].z / c->relPos[i].x / scanSlope;
  2096. X            if (fabs(xs) <= 1.0 && fabs(ys) <= 1.0) {
  2097. X                x = xs * (double) xc + xc;
  2098. X                y = ys * (double) yc + yc;
  2099. X                if (t == i)
  2100. X                    plotPrimaryTarget (c, u, i, x, y);
  2101. X                else
  2102. X                    plotNormalTarget (u, x, y);
  2103. X            }
  2104. X        }
  2105. X    }
  2106. X    return 0;
  2107. X}
  2108. X
  2109. Xint isRadarVisible (c, i)
  2110. Xcraft *c;
  2111. Xint    i; {
  2112. X
  2113. X    register double d, xs, ys;
  2114. X    VPoint    r1;
  2115. X
  2116. X    if (ptbl[i].type == CT_FREE || i == c->index)
  2117. X        return 0;
  2118. X
  2119. X/*
  2120. X *  Is the set on ?
  2121. X */
  2122. X
  2123. X    if (c->radarMode <= RM_STANDBY) {
  2124. X        ptbl[i].rval[c->index] = 0.0;
  2125. X        return 0;
  2126. X    }
  2127. X
  2128. X/*
  2129. X *  Calculate the coordinates of the target relative to the craft's frame.
  2130. X */
  2131. X
  2132. X    r1.x = ptbl[i].Sg.x - c->Sg.x;
  2133. X    r1.y = ptbl[i].Sg.y - c->Sg.y;
  2134. X    r1.z = ptbl[i].Sg.z - c->Sg.z;
  2135. X    VTransform (&r1, &(c->Itrihedral), &(c->relPos[i]));
  2136. X
  2137. X    ptbl[i].rval[c->index] = 0.0;
  2138. X
  2139. X    if (c->relPos[i].x <= 0.0)
  2140. X        return 0;
  2141. X
  2142. X    d = c->relPos[i].x * scanSlope;
  2143. X    xs = c->relPos[i].y / d;
  2144. X    ys = c->relPos[i].z / d;
  2145. X
  2146. X/*
  2147. X *  if the absolute values of xs and ys are both less than 1.0, then
  2148. X *  we are painting this target with radar energy.  Estimate the value of
  2149. X *  the energy that the target sees.
  2150. X */
  2151. X
  2152. X    if ((fabs(xs) <= 1.0) && (fabs(ys) <= 1.0)) {
  2153. X        d = mag(c->relPos[i]);
  2154. X        ptbl[i].rval[c->index] = c->cinfo->radarOutput / (d * d);
  2155. X        if (d >= c->cinfo->radarDRange)
  2156. X            return 0;
  2157. X        else if (d >= c->cinfo->radarTRange)
  2158. X            return 1;
  2159. X        else
  2160. X            return 2;
  2161. X    }
  2162. X    else
  2163. X        return 0;
  2164. X
  2165. X}
  2166. X
  2167. Xint getRadarTarget (c, new)
  2168. Xcraft     *c;
  2169. Xint    new; {
  2170. X
  2171. X    register int    i, minID;
  2172. X    register double minD, d;
  2173. X
  2174. X    for (i=0; i<MAXPLAYERS; ++i)
  2175. X        c->relValid[i] = isRadarVisible(c, i);
  2176. X
  2177. X    if (new == 0) {
  2178. X        i = c->curRadarTarget;
  2179. X        if (i != -1 && c->relValid[i] != 0)
  2180. X            return i;
  2181. X    }
  2182. X
  2183. X    minD = 1000.0 * NM;
  2184. X    minID = -1;
  2185. X    for (i=0; i<MAXPLAYERS; ++i) {
  2186. X        if (c->relValid[i] == 2) {
  2187. X            if (new == 1 && i == c->curRadarTarget)
  2188. X                continue;
  2189. X            d = mag (c->relPos[i]);
  2190. X            if (d < minD) {
  2191. X                minD = d;
  2192. X                minID = i;
  2193. X            }
  2194. X        }
  2195. X    }
  2196. X
  2197. X    return minID;
  2198. X}
  2199. X
  2200. Xvoid doDroneRadar (c)
  2201. Xcraft *c; {
  2202. X
  2203. X    register int i, j;
  2204. X
  2205. X    for (i=0; i<MAXPLAYERS; ++i)
  2206. X        j = isRadarVisible(c, i);
  2207. X}
  2208. X
  2209. Xvoid plotNormalTarget (u, x, y)
  2210. Xviewer *u;
  2211. Xint    x, y; {
  2212. X
  2213. X    XDrawLine (u->dpy, u->rwin, u->gc, x-2, y-2, x-2, y+2);
  2214. X    XDrawLine (u->dpy, u->rwin, u->gc, x-2, y+2, x+2, y+2);
  2215. X    XDrawLine (u->dpy, u->rwin, u->gc, x+2, y+2, x+2, y-2);
  2216. X    XDrawLine (u->dpy, u->rwin, u->gc, x+2, y-2, x-2, y-2);
  2217. X}
  2218. X
  2219. Xextern double heading();
  2220. X
  2221. Xvoid plotPrimaryTarget (c, u, i, x, y)
  2222. Xcraft  *c;
  2223. Xviewer *u;
  2224. Xint    i;
  2225. Xint    x, y; {
  2226. X
  2227. X    int    xp, yp;
  2228. X    char    s[16];
  2229. X    VPoint    rel, deltaV;
  2230. X    double    d, cl;
  2231. X
  2232. X    xp = 150 * u->radarWidth / RADAR_WINDOW_WIDTH;
  2233. X    yp = 150 * u->radarHeight / RADAR_WINDOW_HEIGHT;
  2234. X
  2235. X    XFillRectangle (u->dpy, u->rwin, u->gc, x-3, y-3, 7, 7);
  2236. X
  2237. X/*
  2238. X *  Heading of target
  2239. X */
  2240. X
  2241. X    sprintf (s, "  %3.3d \007", (int) (RADtoDEG(ptbl[i].curHeading)));
  2242. X    XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
  2243. X
  2244. X/*
  2245. X *  Relative heading to target.
  2246. X */
  2247. X
  2248. X    rel.x = ptbl[i].Sg.x - c->Sg.x;
  2249. X    rel.y = ptbl[i].Sg.y - c->Sg.y;
  2250. X    rel.z = ptbl[i].Sg.z - c->Sg.z;
  2251. X    sprintf (s, "  %3.3d R", (int) RADtoDEG(heading(&rel)));
  2252. X    XDrawString (u->dpy, u->rwin, u->gc, xp, yp+u->rfth, s, strlen(s));
  2253. X
  2254. X/*
  2255. X *  Closure rate
  2256. X */
  2257. X
  2258. X    deltaV.x = ptbl[i].Cg.x - c->Cg.x;
  2259. X    deltaV.y = ptbl[i].Cg.y - c->Cg.y;
  2260. X    deltaV.z = ptbl[i].Cg.z - c->Cg.z;
  2261. X    d = mag (rel);
  2262. X    cl = - (deltaV.x * rel.x + deltaV.y * rel.y + deltaV.z + rel.z) /
  2263. X        d / NM * 3600.0;
  2264. X    c->targetDistance = d;
  2265. X    c->targetClosure = cl;
  2266. X    sprintf (s, "%5d C", (int)cl);
  2267. X    XDrawString (u->dpy, u->rwin, u->gc, xp, yp+2*u->rfth, s, strlen(s));
  2268. X
  2269. X/*
  2270. X *  Range to target
  2271. X */
  2272. X
  2273. X    xp = 40 * u->radarWidth / RADAR_WINDOW_WIDTH;
  2274. X    yp = u->rfth + 4;    
  2275. X    sprintf (s, "%d", (int) (d / NM));
  2276. X    XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
  2277. X
  2278. X/*
  2279. X *  Altitude of target
  2280. X */
  2281. X
  2282. X    xp = 150 * u->radarWidth / RADAR_WINDOW_WIDTH;
  2283. X    yp = u->rfth + 4;    
  2284. X    sprintf (s, "%d", (int) (- ptbl[i].Sg.z / 1000.0));
  2285. X    XDrawString (u->dpy, u->rwin, u->gc, xp, yp, s, strlen(s));
  2286. X}
  2287. X
  2288. X/*
  2289. X *  doTEWS :  update the threat display for player i.
  2290. X */
  2291. X
  2292. Xvoid doTEWS (c, u)
  2293. Xcraft    *c;
  2294. Xviewer    *u; {
  2295. X
  2296. X    register int    i, x, y;
  2297. X    VPoint    rel, tmp;
  2298. X    double    m, unit;
  2299. X
  2300. X    XSetForeground (u->dpy, u->gc, u->v->pixel[blackPixel]);
  2301. X    XFillRectangle (u->dpy, u->win, u->gc, u->TEWSx-u->TEWSSize/2,
  2302. X        u->TEWSy-u->TEWSSize/2, u->TEWSSize, u->TEWSSize);
  2303. X    XSetForeground (u->dpy, u->gc, u->v->pixel[whitePixel]);
  2304. X
  2305. X    XDrawArc(u->dpy, u->win, u->gc, u->TEWSx-u->TEWSSize/2,
  2306. X        u->TEWSy-u->TEWSSize/2, u->TEWSSize, u->TEWSSize,
  2307. X        0, 360*64);
  2308. X
  2309. X    for (i=0; i<MAXPLAYERS; ++i) {
  2310. X
  2311. X        if (c->index == i)
  2312. X            continue;
  2313. X
  2314. X        if (c->rval[i] > c->cinfo->TEWSThreshold) {
  2315. X            tmp.x = ptbl[i].Sg.x - c->Sg.x;
  2316. X            tmp.y = ptbl[i].Sg.y - c->Sg.y;
  2317. X            tmp.z = ptbl[i].Sg.z - c->Sg.z;
  2318. X            VTransform (&tmp, &(c->Itrihedral), &(rel));
  2319. X            m = mag(rel);
  2320. X            rel.x /= m;
  2321. X            rel.y /= m;
  2322. X            rel.z /= m;
  2323. X            unit = sqrt (rel.x * rel.x + rel.y * rel.y);
  2324. X            if (unit == 0.0) {
  2325. X                rel.x = 1.0;
  2326. X                rel.y = 0.0;
  2327. X            }
  2328. X            x = u->TEWSx + (int) (rel.y * u->TEWSSize * 0.4 / unit);
  2329. X            y = u->TEWSy - (int) (rel.x * u->TEWSSize * 0.4 / unit);
  2330. X            if (c->team == ptbl[i].team) {
  2331. X                XDrawLine (u->dpy, u->win, u->gc, x-2, y-2, x-2, y+2);
  2332. X                XDrawLine (u->dpy, u->win, u->gc, x-2, y+2, x+2, y+2);
  2333. X                XDrawLine (u->dpy, u->win, u->gc, x+2, y+2, x+2, y-2);
  2334. X                XDrawLine (u->dpy, u->win, u->gc, x+2, y-2, x-2, y-2);
  2335. X            }
  2336. X            else
  2337. X                XFillRectangle (u->dpy, u->win, u->gc, x-3, y-3, 7, 7);
  2338. X        }
  2339. X    }
  2340. X}
  2341. *-*-END-of-./fsim/doRadar.c-*-*
  2342. echo x - ./fsim/flaps3.xbm
  2343. sed 's/^X//' >./fsim/flaps3.xbm <<'*-*-END-of-./fsim/flaps3.xbm-*-*'
  2344. X#define flaps3_width 64
  2345. X#define flaps3_height 32
  2346. X#define flaps3_x_hot -1
  2347. X#define flaps3_y_hot -1
  2348. Xstatic char flaps3_bits[] = {
  2349. X   0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xdd, 0xfd,
  2350. X   0x1f, 0x00, 0x00, 0x00, 0x20, 0xef, 0xee, 0xee, 0xee, 0xff, 0x03, 0x00,
  2351. X   0x30, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x3f, 0x00, 0x38, 0xbb, 0xbb, 0xbb,
  2352. X   0xbb, 0x7b, 0x00, 0x00, 0x28, 0xdf, 0xdd, 0xdd, 0xdd, 0x3d, 0x0c, 0x00,
  2353. X   0x6c, 0xfe, 0xff, 0xff, 0xff, 0x1f, 0x3c, 0x00, 0x3c, 0x00, 0x00, 0x00,
  2354. X   0x00, 0x00, 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00,
  2355. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
  2356. X   0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
  2357. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
  2358. X   0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
  2359. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
  2360. X   0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2361. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2362. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2363. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2364. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2365. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2366. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2367. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2368. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2369. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2370. X   0x00, 0x00, 0x00, 0x00};
  2371. *-*-END-of-./fsim/flaps3.xbm-*-*
  2372. echo x - ./fsim/flaps0.xbm
  2373. sed 's/^X//' >./fsim/flaps0.xbm <<'*-*-END-of-./fsim/flaps0.xbm-*-*'
  2374. X#define flaps0_width 64
  2375. X#define flaps0_height 32
  2376. X#define flaps0_x_hot 4
  2377. X#define flaps0_y_hot 25
  2378. Xstatic char flaps0_bits[] = {
  2379. X   0x00, 0xf0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xdf, 0xdd, 0xfd,
  2380. X   0x1f, 0x00, 0x00, 0x00, 0x60, 0xef, 0xee, 0xee, 0xee, 0x1f, 0x00, 0x00,
  2381. X   0x70, 0x77, 0x77, 0x77, 0x77, 0xf7, 0x03, 0x00, 0x50, 0xbb, 0xbb, 0xbb,
  2382. X   0xbb, 0x7b, 0x7f, 0x00, 0x50, 0xdf, 0xdd, 0xdd, 0xdd, 0xbd, 0xff, 0x07,
  2383. X   0xe0, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
  2384. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2385. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2386. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2387. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2388. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2389. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2390. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2391. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2392. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2393. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2394. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2395. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2396. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2397. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2398. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2399. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2400. X   0x00, 0x00, 0x00, 0x00};
  2401. *-*-END-of-./fsim/flaps0.xbm-*-*
  2402. echo x - ./fsim/exp.xbm
  2403. sed 's/^X//' >./fsim/exp.xbm <<'*-*-END-of-./fsim/exp.xbm-*-*'
  2404. X#define exp_width 64
  2405. X#define exp_height 64
  2406. Xstatic char exp_bits[] = {
  2407. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2408. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00,
  2409. X   0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
  2410. X   0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xc2, 0x61, 0x00, 0x03,
  2411. X   0x00, 0x00, 0x00, 0x20, 0xc2, 0x21, 0x80, 0x03, 0x00, 0x00, 0x1c, 0x40,
  2412. X   0xc0, 0x21, 0x80, 0x03, 0x00, 0x80, 0x30, 0x40, 0x80, 0x38, 0x80, 0x01,
  2413. X   0x00, 0x80, 0x09, 0xa3, 0x82, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x11, 0x02,
  2414. X   0xc2, 0x22, 0x40, 0x00, 0x00, 0x00, 0x86, 0x84, 0xc4, 0x00, 0x40, 0x00,
  2415. X   0x00, 0x00, 0x80, 0x14, 0xc6, 0x02, 0x50, 0x00, 0xc0, 0x00, 0x0c, 0x8a,
  2416. X   0xe9, 0x00, 0x00, 0x00, 0xc0, 0x01, 0xa8, 0x18, 0xd3, 0x75, 0x02, 0x08,
  2417. X   0x80, 0x01, 0xe0, 0x04, 0x3e, 0x03, 0x01, 0x04, 0x00, 0x05, 0x10, 0x92,
  2418. X   0x8a, 0x0e, 0x06, 0x07, 0x00, 0x5c, 0x81, 0xf1, 0xef, 0x1b, 0x00, 0x02,
  2419. X   0x00, 0x18, 0x80, 0x0c, 0xcf, 0x0b, 0xa5, 0x00, 0x00, 0x60, 0x88, 0x17,
  2420. X   0xef, 0x07, 0x87, 0x00, 0x00, 0xa0, 0x21, 0x79, 0xc7, 0x55, 0x23, 0x00,
  2421. X   0x00, 0x90, 0x40, 0x3f, 0xeb, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x40, 0x9f,
  2422. X   0xef, 0xbc, 0x17, 0x00, 0x00, 0xa4, 0x05, 0x9e, 0x2f, 0x71, 0x06, 0x00,
  2423. X   0x00, 0x08, 0x00, 0x6f, 0x5f, 0xbc, 0x02, 0x00, 0x00, 0x40, 0xf9, 0x3c,
  2424. X   0x01, 0xbf, 0x03, 0x00, 0x00, 0x00, 0xac, 0xb3, 0x5f, 0xfd, 0x03, 0x00,
  2425. X   0x00, 0x00, 0xfc, 0xbb, 0x4f, 0xa7, 0x0b, 0x10, 0x00, 0x00, 0xd7, 0xad,
  2426. X   0xc2, 0x9a, 0x0d, 0x04, 0x00, 0x40, 0xfb, 0xc9, 0x98, 0x79, 0x11, 0x19,
  2427. X   0x00, 0xc0, 0xfa, 0x8d, 0x18, 0xcb, 0x3b, 0x02, 0x00, 0x80, 0xdd, 0x0d,
  2428. X   0x88, 0x0b, 0x5f, 0x08, 0x00, 0xc0, 0x2d, 0x39, 0x60, 0x1b, 0xfa, 0x00,
  2429. X   0x00, 0xd0, 0x7e, 0x97, 0xc1, 0x73, 0x58, 0x03, 0x00, 0x6b, 0xb1, 0x0e,
  2430. X   0x01, 0xfb, 0x1c, 0x02, 0x00, 0x80, 0xdf, 0x15, 0x81, 0x54, 0xec, 0x02,
  2431. X   0x00, 0x00, 0xfe, 0xff, 0xa2, 0xd9, 0x3c, 0x00, 0x00, 0x80, 0x7f, 0xde,
  2432. X   0xc2, 0xac, 0xb4, 0x02, 0x00, 0x00, 0x33, 0xde, 0xec, 0x0b, 0x3e, 0x02,
  2433. X   0x00, 0xc0, 0x6c, 0x17, 0xe1, 0xe7, 0xbc, 0x03, 0x00, 0x50, 0x76, 0xfd,
  2434. X   0xf7, 0xfe, 0xff, 0x00, 0x00, 0x1c, 0x5d, 0x9c, 0xfa, 0xba, 0xe9, 0x00,
  2435. X   0x00, 0x05, 0x63, 0xcc, 0x0e, 0xec, 0x99, 0x00, 0x00, 0x46, 0x82, 0x94,
  2436. X   0x80, 0xff, 0x3a, 0x00, 0x80, 0x03, 0xe3, 0xd7, 0x89, 0xcb, 0x27, 0x00,
  2437. X   0x00, 0x80, 0x21, 0x8f, 0x84, 0xc9, 0x3f, 0x00, 0x00, 0x00, 0x04, 0xff,
  2438. X   0xcc, 0xdb, 0xe3, 0x01, 0x00, 0xa0, 0x00, 0xa6, 0x7e, 0x0b, 0xb1, 0x07,
  2439. X   0x00, 0x00, 0x00, 0x19, 0x6f, 0x6e, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x9c,
  2440. X   0xfa, 0x53, 0x06, 0x02, 0x00, 0x00, 0x00, 0x04, 0xe7, 0xa9, 0x00, 0x06,
  2441. X   0x00, 0x00, 0x80, 0x43, 0x14, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
  2442. X   0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x0c, 0x40, 0x00, 0x00,
  2443. X   0x00, 0x00, 0x40, 0x05, 0x08, 0x20, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00,
  2444. X   0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x03, 0x00,
  2445. X   0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00,
  2446. X   0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00,
  2447. X   0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x14, 0x00,
  2448. X   0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00,
  2449. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00};
  2450. *-*-END-of-./fsim/exp.xbm-*-*
  2451. -- 
  2452. Riley Rainey            Internet: riley@mips.com
  2453. MIPS Computer Systems        Phone:    +1 214 770-7979
  2454. Dallas, Texas
  2455.  
  2456. dan
  2457. ----------------------------------------------------
  2458. O'Reilly && Associates   argv@sun.com / argv@ora.com
  2459. Opinions expressed reflect those of the author only.
  2460.